var currentAreaCode = ''; //当前选择街道码
var currentareaName = '所有'; //当前选择街道名称
var currentSiteId = JSON.parse(localStorage.getItem('loginUser')).projectId; //当前选择工地ID
var currentSiteName = ''; //当前选择工地名称
$(document).ready(function() {

	// document.getElementById('iframe').onload = function() {
	// 	console.log("ahahahhaha");
	// 	setTimeout(function() {
	// 		console.log(document.getElementById('iframe').contentWindow.document.getElementById(
	// 			'logout'));
	// 		console.log("还是说说");
	// 	}, 5000);
	// 	document.getElementById('iframe') //获取到iframe
	// 		.contentWindow //获取到iframe的window
	// 		.document //获取到iframe的document
	// 		.getElementById('logout') //正常获取元素
	// 		.style.color = "orange"; //修改样式
	// };


	var indexmap, map;


	$('.site-top-item').click(function() {
		$(this).addClass("selected").siblings().removeClass("selected");
	})
	$('.mid-approval-search-status>div').click(function() {
		$(this).addClass("selected").siblings().removeClass("selected");
		approvalParam.type = $(this).context.dataset.type;
		loadApprovalTable(approvalParam)
	})
	$('.mid-fireeye-table-tool>div').click(function() {
		$(this).addClass("selected").siblings().removeClass("selected");
		fireeyeParam.type = $(this).context.dataset.type;
		fireeyeParam.deviceName = $("#fireeye_deviceName").val();
		loadFireeyeTable(fireeyeParam);
	})
	// $('.mid-fireeye-table-tool>div').click(function() {
	//     $(this).addClass("selected").siblings().removeClass("selected");
	//     electricalSafetyParam.type = $(this).context.dataset.type;
	//     loadelectricalSafetyTable(electricalSafetyParam)
	// })
	//电器安全
	$('.mid-electricalSafety-table-tool>div').click(function() {
		$(this).addClass("selected").siblings().removeClass("selected");
		electricalSafetyParam.type = $(this).context.dataset.type;
		electricalSafetyParam.deviceName = $("#electricalSafety_deviceName").val();
		loadelectricalSafetyTable(electricalSafetyParam)
	})
	$('.electricalSafety_tab').on('click',function(){
		$(this).addClass('maintt-item-sel').siblings().removeClass('maintt-item-sel')
		if($(this).attr('data-index') == 1){
			$('.details-electricalSafety-body').show();
			$('.electricalSafety-table-history').hide();
		}else{
			$('.details-electricalSafety-body').hide();
			$('.electricalSafety-table-history').show();
			let deviceId = $(this).attr('data-deviceId');
			loadelectricalSafetyTable_history(deviceId)
		}
	})
	//烟感
	$('.mid-yangan-table-tool>div').click(function() {
	    $(this).addClass("selected").siblings().removeClass("selected");
	    yanganParam.type = $(this).context.dataset.type;
		yanganParam.deviceName = $('#yangan_deviceName').val();
	    loadyanganTable(yanganParam)
	})
	$('.yangan_tab').on('click', function() {
		$(this).addClass('maintt-item-sel').siblings().removeClass('maintt-item-sel')
		if ($(this).attr('data-index') == 1) {
			$('.details-yangan-body').show();
			$('.yangan-table-history').hide();
		} else {
			$('.details-yangan-body').hide();
			$('.yangan-table-history').show();
			// let deviceId = $(this).attr('data-deviceId');
			// loadyanganTable_history(deviceId)
		}
	})
	//水箱
	$('.mid-shuixiang-table-tool>div').click(function() {
	    $(this).addClass("selected").siblings().removeClass("selected");
	    shuixiangParam.type = $(this).context.dataset.type;
		shuixiangParam.deviceName = $('.mid-shuixiang-table-tool input').eq(1).val();
	    loadshuixiangTable(shuixiangParam)
	})
	$('.shuixiang_tab').on('click', function() {
		$(this).addClass('maintt-item-sel').siblings().removeClass('maintt-item-sel')
		if ($(this).attr('data-index') == 1) {
			$('.details-shuixiang-body').show();
			$('.shuixiang-table-history').hide();
		} else {
			$('.details-shuixiang-body').hide();
			$('.shuixiang-table-history').show();
			// let deviceId = $(this).attr('data-deviceId');
			// loadshuixiangTable_history(deviceId)
		}
	})
	//泵水压
	$('.mid-bengshuiya-table-tool>div').click(function() {
	    $(this).addClass("selected").siblings().removeClass("selected");
	    bengshuiyaParam.type = $(this).context.dataset.type;
		bengshuiyaParam.deviceName = $('.mid-bengshuiya-table-tool input').eq(1).val();
	    loadbengshuiyaTable(bengshuiyaParam)
	})
	$('.bengshuiya_tab').on('click', function() {
		$(this).addClass('maintt-item-sel').siblings().removeClass('maintt-item-sel')
		if ($(this).attr('data-index') == 1) {
			$('.details-bengshuiya-body').show();
			$('.bengshuiya-table-history').hide();
		} else {
			$('.details-bengshuiya-body').hide();
			$('.bengshuiya-table-history').show();
			// let deviceId = $(this).attr('data-deviceId');
			// loadshuixiangTable_history(deviceId)
		}
	})
	
	$('#site-menu2').click(function() {
		$('.left-site-fireeye.viewbox-left-site-box').removeClass("hidden-view").siblings().addClass(
			"hidden-view");
		$('.mid-site-fireeye.viewbox-mid-site-box').removeClass("hidden-view").siblings().addClass(
			"hidden-view");
		fireEyesCurrentStatus(3);
		fireeyeCardPageByProject();
		$('.mid-site-fireeye-search-params input').val("")

	})
	$('#site-menu1').click(function() {
		$('.left-site-record.viewbox-left-site-box').removeClass("hidden-view").siblings().addClass(
			"hidden-view");
		$('.mid-site-record.viewbox-mid-site-box').removeClass("hidden-view").siblings().addClass(
			"hidden-view");
		fireRecordByThirtyDays()
		loadFireRecordTable(1)
		searchType = 1;
		$('.mid-site-record-tool input').val("")
	})
	$('#site-menu3').click(function() {
		$('.left-site-inspection.viewbox-left-site-box').removeClass("hidden-view").siblings().addClass(
			"hidden-view");
		$('.mid-site-record.viewbox-mid-site-box').removeClass("hidden-view").siblings().addClass(
			"hidden-view");
		fireInspectionByThirtyDays()
		loadFireRecordTable(2)
		searchType = 2;
		$('.mid-site-record-tool input').val("")
	})
	$('#site-menu4').click(function() {
		$('.left-site-plan.viewbox-left-site-box').removeClass("hidden-view").siblings().addClass(
			"hidden-view");
		$('.mid-site-plan.viewbox-mid-site-box').removeClass("hidden-view").siblings().addClass(
			"hidden-view");
		queryPlanBySite();
	})
	$('#site-menu5').click(function() {
		$('.viewbox-left-site-box').addClass("hidden-view");
		$('.mid-site-safetyAccount.viewbox-mid-site-box').removeClass("hidden-view").siblings()
			.addClass("hidden-view");
		// queryPlanBySite();
		loadSafetyAccountTable('');
	})
	
	
	// $('.maintt-item').on('click',function(){
	// 	$(this).addClass('maintt-item-sel').siblings().removeClass('maintt-item-sel')
	// 	if($(this).attr('data-index') == 1){
	// 		$('.details-fireeye-body>ul').show();
	// 		$('#multibandfire-table-history').hide();
	// 	}else{
	// 		$('.details-fireeye-body>ul').hide();
	// 		$('#multibandfire-table-history').show();
	// 		let deviceId = $(this).attr('data-deviceId');
	// 		loadFireeyeTable_history(deviceId)
	// 	}
	// })
	


	layui.use('form', function() {
		var form = layui.form;
		form.on('select(selfilter2)', function(data) {
			console.log(data.value);
			loadSafetyAccountTable(data.value);
		});
	})

})
////页面加载执行结束
//首页地图初始化
function initIndexMap() {
	indexmap = new AMap.Map('mid-index-con-map', {
		viewMode: '3D',
		zoom: 10,
		expandZoomRange: true,
		buildingAnimation: true, //楼块出现是否带动画
		zooms: [3, 20],
		rotation: 8,
		pitch: 50,
		center: [121.404195, 31.186536],
		features: ['bg', 'road', 'building', 'point'],
		layers: [
			// 高德默认标准图层
			new AMap.TileLayer(),
			// 楼块图层
			new AMap.Buildings({
				zooms: [3, 18],
				zIndex: 10,
				heightFactor: 3 //2倍于默认高度，3D下有效
			})
		],
		mapStyle: 'amap://styles/6f2ac55a0fce7bb44145e64373f74f99',
	});
	Ajax('/gov/project/list/all', overCallback)

	function overCallback(res) {
		var markers = [];
		$.each(res.result, function(index, el) {
			el.longitude = bd_toGd(el.longitude, el.latitude).lng;
			el.latitude = bd_toGd(el.longitude, el.latitude).lat;
			var marker = new AMap.Marker({
				position: new AMap.LngLat(el.longitude, el.latitude),
				icon: '../static/img/images/icon47.png',
			}); // 创建点实例
			markers.push(marker);
		})
		var markerGroup = new AMap.OverlayGroup(markers);
		indexmap.add(markerGroup);
		indexmap.setFitView();
	}
}

/*查询各街道工地数量*/
queryNumberForStreet = () => {

	Ajax('/gov/index/project/countbycommunity', callBack)

	function callBack(res) {
		$.each(res.result, function(index, el) {
			if (window.location.hash.indexOf('index') > -1) {
				$('#index-street-' + el.areaCode).html(el.projectNum);
			} else {
				$('#street-' + el.areaCode).html(el.projectNum);
				$('#street-' + el.areaCode).val(el.areaName)
			}
		});
	}
}



/*点击街道查询工地*/
$('.street-count').click(function() {
	$(this).addClass("selected").siblings().removeClass("selected");
	currentAreaCode = $(this).context.id.substring(7);
	currentareaName = $(this).val();
	queryAllSite();
})
/*根据名称查询工地*/
$('#searchSite').click(function() {
	queryAllSite($('.left-site-list-search>input').val());
})

/*首页首页统计信息*/
overviewIndex = (type) => {

	Ajax('/gov/index/statistics', callBack)

	function callBack(res) {
		if (type == 1) {
			$('.index-top-item').eq(0).find('div').eq(2).html(res.result.projectNum);
			$('.index-top-item').eq(1).find('div').eq(2).html(res.result.toExamineNum);
			$('.index-top-item').eq(2).find('div').eq(2).html(res.result.deviceNum + res.result.fireProtectionNum);
			$('.index-top-item').eq(3).find('div').eq(2).html(res.result.monitorDays);
		} else if (type == 2) {
			$('.map-top-item').eq(0).find('div').eq(2).html(res.result.projectNum);
			$('.map-top-item').eq(1).find('div').eq(2).html(res.result.toExamineNum);
			$('.map-top-item').eq(2).find('div').eq(2).html(res.result.deviceNum);
			$('.map-top-item').eq(3).find('div').eq(2).html(res.result.monitorDays);
		}

	}
}

/*近30天动火申请排名*/
fireApplyRankingByThirtyDays = () => {
	$('.left-index-mid-con').html('');
	Ajax('/gov/index/fireapply/countthirtydaysbyproject?num=' + 4, callBack)

	function callBack(res) {
		let str = '';
		$.each(res.result, function(index, el) {
			str = str + `<div class="index-mid-item">
                                <div class="index-mid-item-img">
                                    <img src="/images/${el.imagePath}">
                                </div>
                                <div class="index-mid-item-tit">
                                    <span>${el.shortName}</span>
                                    <span>动火申请</span>
                                    <span>${el.applyNum}次</span>
                                </div>
                            </div>`
		});
		$('.left-index-mid-con').append(str);
	}
}


/*当前多频谱画面*/
fireEyesCurrentStatus = (flag) => {
	if (flag == 1) {
		$('.right-index-top-msg>ul').html('');
		$('.right-index-top-img').html('');
		var url = '/gov/multibandfire/list?pageNum=1&pageSize=1&type=' + '';
	} else if (flag == 2) {
		$('.left-fireeye-top>.main-tit>span').html('');
		$('.left-fireeye-top-msg>ul').html('');
		$('.left-fireeye-top-img').html('');
		var url = '/gov/multibandfire/list?pageNum=1&pageSize=1&type=' + '';
	} else if (flag == 3) {
		$('.left-site-fireeye-con').html('');
		$('.left-site-fireeye>.main-tit>span').html('');
		var url = '/project/multibandfire/list?pageNum=1&pageSize=1&type=&projectId=' + currentSiteId;
	}


	Ajax(url, callBack)

	function callBack(res) {
		let data = res.result.data[0];
		if (flag == 1) {
			let str = '';
			str = str + `<li>设备名称：${data.deviceName}</li>
                     <li>动&nbsp;&nbsp;火&nbsp;点：${data.fireLocale?data.fireLocale:''}</li>
                     <li>上报时间：${checkNullOrEmpty(data.time)}</li>
                     <li>当前状态：${data.eventTypeDesc}</li>`
			$('.right-index-top-msg>ul').append(str);
			$('.right-index-top-img').append(`<img src="/images/${data.filePath}">`);

		} else if (flag == 2) {
			$('.left-fireeye-top>.main-tit>span').append(`
                设备状态：${data.eventTypeDesc}
                `)
			let str = '';
			str = str + `<li>设备名称：${data.deviceName}</li>
                     <li>动&nbsp;&nbsp;火&nbsp;点：${data.fireLocale?data.fireLocale:''}</li>
                     <li>上报时间：${data.time}</li>`
			$('.left-fireeye-top-msg>ul').append(str);
			$('.left-fireeye-top-img').append(`<img src="/images/${data.filePath}">`);
		} else if (flag == 3) {
			$('.left-site-fireeye>.main-tit>span').append(`
                上报时间: ${data.time}
                `)
			let str = '';
			str = str + `<img src="/images/${data.filePath}">
                         <div class="left-site-fireeye-msg">
                         <div>设备名称：${data.deviceName}</div>
                         <div>设备状态: ${data.eventTypeDesc}</div>
                         <div>所属工地:${data.projectName}</div>
                         <div>动 火 点: ${data.fireLocale?data.fireLocale:''}</div></div>`
			$('.left-site-fireeye-con').append(str);
		}

	}
}



/*当前告警通知*/

fireEyesCurrentWarnStatus = (type) => {
	if (type == 1) {
		var num = 2;
		$('.mid-index-msg').html('');
	} else if (type == 2) {
		var num = 4;
		$('.right-fireeye-list-table>ul').html('');
	} else if (type == 3) {
		var num = 2;
		$('.right-map-list-table>ul').html('');
	}
	Ajax('/gov/multibandfire/list?pageNum=1&type=&pageSize=' + num, callBack)

	function callBack(res) {
		if (type == 1) {
			let str = ` <div class="mid-index-msg-list list-tit">
                            <div style="flex:1;"></div>
                            <div>工地名称</div>
                            <div>动火点</div>
                            <div>状态</div>
                            <div>时间</div>
                        </div>`;
			$.each(res.result.data, function(index, el) {
				str = str + `<div class="mid-index-msg-list">
                            <div style="flex:1;">
                                <img src="../static/img/images/icon14.png">
                            </div>
                            <div>${el.projectName}</div>
                            <div>${el.fireLocale?data.fireLocale:''}</div>
                            <div>${el.eventTypeDesc}</div>
                            <div>${el.time}</div>
                        </div>`
			});
			$('.mid-index-msg').append(str);
		} else if (type == 2) {
			let str = ``;
			$.each(res.result.data, function(index, el) {
				str = str + `<li>
                                    <div style="flex: 1;">
                                        <img src="../static/img/images/icon14.png">
                                    </div>
                                    <div style="flex: 2;">${el.projectName}</div>
                                    <div style="flex: 2;">${el.fireLocale?data.fireLocale:''}</div>
                                    <div style="flex: 1;">${el.eventTypeDesc}</div>
                                    <div style="flex: 3;">${el.time}</div>
                                </li>`
			});
			$('.right-fireeye-list-table>ul').append(str);
		} else if (type == 3) {
			let str = ``;
			$.each(res.result.data, function(index, el) {
				str = str + `<li>
                                    <div style="flex: 1;">
                                        <img src="../static/img/images/icon14.png">
                                    </div>
                                    <div style="flex: 2;">${el.projectName}</div>
                                    <div style="flex: 2;">${el.fireLocale?data.fireLocale:''}</div>
                                    <div style="flex: 1;">${el.eventTypeDesc}</div>
                                    <div style="flex: 3;">${el.time}</div>
                                </li>`
			});
			$('.right-map-list-table>ul').append(str);
		}

	}
}



/*查询所有工地列表*/
queryAllSite = (siteName, flag) => {
	if (flag) {
		currentAreaCode = '';
		currentareaName = '所有';
	}
	if (!siteName) {
		siteName = ''
	}
	$('#left-site-list-scall').html('');
	layui.use('flow', function() {
		var $ = layui.jquery;
		var flow = layui.flow;
		flow.load({
			elem: '#left-site-list-scall',
			scrollElem: '.left-site-list-body',
			done: function(page, next) {
				var lis = [];
				Ajax('/gov/project/list?pageNum=' + page + '&pageSize=5&name=' + siteName +
					'&areaCode=' + currentAreaCode, callBack);

				function callBack(res) {
					let data = res.result.data;
					let pages = Math.ceil(res.result.total / 5);
					$('.left-site-list-con>.main-tit>label').html(currentareaName + '工地 —— ' +
						res.result.total + '个');

					layui.each(data, function(index, item) {
						lis.push(`<div class="left-site-list-item" onclick=showSiteDetail(${item.id})>
                                        <div>${item.name}</div>
                                        <div>
                                            <img src="/images/${item.imagePath}">
                                            <ul>
                                                <li>负责人：${item.chargePerson}</li>
                                                <li>电 话：${item.cellphone}</li>
                                                <li>地 址：${item.address}</li>
                                            </ul>
                                        </div>
                                        <div></div>
                                    </div>`);
					});
					next(lis.join(''), page < pages);
					if (page == 1) {
						$('#left-site-list-scall').find('.left-site-list-item').eq(0).click();
					}
				}
			}
		});
	});
}


/*查看工地详细信息*/
showSiteDetail = (projectId) => {

	Ajax('/project/info?projectId=' + projectId, callBack)

	function callBack(res) {
		currentSiteId = res.result.id;
		currentSiteName = res.result.name;

		$('.right-site-bottom>.main-tit>label').html(res.result.name + '详情');
		$('.right-site-bottom-msg>ul>li').eq(0).find('span').html(res.result.name);
		$('.right-site-bottom-msg>ul>li').eq(1).find('span').html(res.result.address);
		$('.right-site-bottom-msg>ul>li').eq(2).find('span').html(res.result.contractCompany);
		$('.right-site-bottom-msg>ul>li').eq(3).find('span').html(res.result.chargePerson);
		$('.right-site-bottom-msg>ul>li').eq(4).find('span').html(res.result.cellphone);
		$('.right-site-bottom-msg>ul>li').eq(5).find('span').html(res.result.areaName);
		$('.right-site-bottom-msg>ul>li').eq(6).find('span').html(res.result.status);
		$('.right-site-bottom-msg>ul>li').eq(7).find('span').html(`
            <img src="/images/${res.result.imagePath}">`);
	}
}


/*查看当前工地应急预案*/
queryPlanBySite = () => {

	Ajax('/project/emergencyplan/list?pageNum=1&pageSize=99&projectId=' + currentSiteId, callBack)

	function callBack(res) {
		$('.left-site-plan>.main-tit>label').html(currentSiteName + ' — 应急预案总数');
		$('.mid-site-plan>.main-tit>label').html(currentSiteName + ' — 应急预案');
		$('#left-site-plan-count').html('共' + res.result.total + '个');
		let str = '';
		$.each(res.result.data, function(index, el) {
			str = str + ` <div class="mid-site-plan-list-item">
                                <img src="../static/img/images/icon27.png">
                                <span>${el.name}</span>
                                <div onclick=window.open("/images/${el.filePath}")>查看</div>
                            </div>`
		});
		$('.mid-site-plan-list').append(str);

	}
}

//安全台账记录表格
function loadSafetyAccountTable(FileType) {
	$('.mid-site-safetyAccount>.main-tit>label').html(currentSiteName + ' —— 安全台账');
	console.log(FileType);
	var url = ajaxPrefix() + '/manage/file/list';
	layui.use('table', function() {
		var table = layui.table;
		//第一个实例
		table.render({
			title: '',
			text: {
				none: '暂无数据'
			},
			elem: '#mid-site-safetyAccount-list',
			skin: 'nob',
			url: url,
			headers: {
				SessionId: localStorage.getItem('sessionId')
			},
			where: {
				pageSize: 6,
				projectId: currentSiteId,
				fileType: FileType,
			},
			parseData: function(res) { //res 即为原始返回的数据
				return {
					"code": res.status == 200 ? 0 : 1, //解析接口状态
					"msg": res.message, //解析提示文本
					"count": res.result.total, //解析数据长度
					"data": res.result.data //解析数据列表
				};
			},
			request: {
				pageName: 'pageNum', //页码的参数名称，默认：page
				limitName: 'pageSize' //每页数据量的参数名，默认：limit
			},
			page: {
				limit: 6,
			} //开启分页
			,
			cols: [
				[{
						field: 'projectName',
						title: '所属工地',
						align: 'center'
					},
					{
						field: 'name',
						title: '文件名',
						align: 'center'
					}, {
						field: 'fileType',
						title: '文件类型',
						align: 'center',
					}, {
						field: 'updateTime',
						title: '上传时间',
						templet: function(d) {
							return d.updateTime == undefined ? '暂无' : d.updateTime
						},
						align: 'center'
					}, {
						title: '操作',
						align: 'center',
						width: 120,
						templet: function(d) {
							return `<a style="color:#54A1F1" href="http://dev.njdtwise.com/images/` +
								d.filePath + `" download="http://dev.njdtwise.com/images/` + d
								.filePath + `">下载</a>`
						},
					},
				]
			]
		});
	});
}


var infoWindow = new AMap.InfoWindow({
	offset: new AMap.Pixel(12, -30),
	//closeWhenClickMap: true
});
//地图初始化
function initMap() {
	map = new AMap.Map('viewbox-mid-map', {
		viewMode: '3D',
		zoom: 10,
		expandZoomRange: true,
		buildingAnimation: true, //楼块出现是否带动画
		zooms: [3, 20],
		rotation: 8,
		pitch: 50,
		center: [121.404195, 31.186536],
		features: ['bg', 'road', 'building', 'point'],
		layers: [
			// 高德默认标准图层
			new AMap.TileLayer(),
			// 楼块图层
			new AMap.Buildings({
				zooms: [3, 18],
				zIndex: 10,
				heightFactor: 3 //2倍于默认高度，3D下有效
			})
		],
		mapStyle: 'amap://styles/6f2ac55a0fce7bb44145e64373f74f99',
	});
	map.on('click', function(e) {
		infoWindow.close();
		console.log(e.lnglat.getLng() + ',' + e.lnglat.getLat())
	});

	Ajax('/gov/project/list/all', overCallback)

	function overCallback(res) {
		var markers = [];
		$.each(res.result, function(index, el) {
			el.longitude = bd_toGd(el.longitude, el.latitude).lng;
			el.latitude = bd_toGd(el.longitude, el.latitude).lat;
			var marker = new AMap.Marker({
				position: new AMap.LngLat(el.longitude, el.latitude),
				icon: '../static/img/images/icon47.png',
			}); // 创建点实例
			marker.content = `<div style="width:4.8rem;height:2.6rem;">
                                  <div class="main-tit" style="border-bottom: 1px solid #54A1F1;">
                                        <img src="../static/img/images/icon33.png">
                                        ${el.name}详情
                                   </div>
                                   <div  class="info-window-con" style="margin-top:0.2rem;">
                                     <ul>
                                        <li class="info-window-li">
                                            <div>工地名称：</div>
                                            <span>${el.name}</span>
                                        </li>
                                        <li class="info-window-li">
                                            <div>地址：</div>
                                            <span>${el.address}</span>
                                        </li>
                                        <li class="info-window-li">
                                            <div>施工单位：</div>
                                            <span>${el.contractCompany}</span>
                                        </li>
                                        <li class="info-window-li">
                                            <div>负责人：</div>
                                            <span>${el.chargePerson}</span>
                                        </li>
                                        <li class="info-window-li">
                                            <div>联系方式：</div>
                                            <span>${el.cellphone}</span>
                                        </li>
                                        <li class="info-window-li">
                                            <div>工地类型：</div>
                                            <span>${el.type}</span>
                                        </li>
                                        <li class="info-window-li">
                                            <div>照片：</div>
                                            <img src="/images/${el.imagePath}">
                                        </li>
                                    </ul>
                                  </div>
                              </div>`
			marker.on('click', function(e) {
				infoWindow.setContent(e.target.content);
				infoWindow.open(map, e.target.getPosition());
				map.setFitView();
			});
			markers.push(marker);
		})
		var markerGroup = new AMap.OverlayGroup(markers);
		map.add(markerGroup);
		map.setFitView();
	}

}
/*近7天动火申请折线图*/
function fireApplyBySevenDays() {
	Ajax('/gov/index/fireapply/countsevendays', overCallback)

	function overCallback(res) {
		let data = res.result
		let timeData = []
		let warningStatusData = []
		$.each(data, function(index, el) {
			timeData.push(index)
			warningStatusData.push(el)
		});
		var option = {
			color: '#fff',
			grid: {
				top: '10%',
				left: '5%',
				right: '10%',
				bottom: '5%',
				containLabel: true
			},
			tooltip: {
				trigger: 'axis'
			},
			xAxis: [{
				type: 'category',
				boundaryGap: false,
				data: timeData,
				axisTick: {
					alignWithLabel: true
				},
				axisTick: {
					alignWithLabel: true
				},
				axisLine: {
					show: true,
					lineStyle: {
						color: '#54A1F1',
						width: 2
					}
				},
				axisLabel: {
					color: 'white',
					fontSize: '10'
				},
				axisTick: {
					show: false
				},
			}],
			yAxis: [{
				type: 'value',
				minInterval: 1,
				axisLine: {
					show: true,
					lineStyle: {
						color: '#54A1F1',
						width: 2
					}
				},
				splitLine: {
					lineStyle: {
						color: '#112B6F'
					}
				},
				axisLabel: {
					color: 'white',
					fontSize: '10'
				},
				axisTick: {
					show: false
				},
			}],
			series: [{
				data: warningStatusData,
				type: 'line',
				smooth: true,
				areaStyle: {
					color: 'rgba(84, 161, 241, 1)'
				},
			}]
		};
		var myChart = echarts.init(document.getElementById('left-index-bottom-chart'));
		//使用制定的配置项和数据显示图表
		myChart.setOption(option);
	}
}


/*动火审批概览*/
approvalOverSize = () => {
	Ajax('/gov/fireapply/examinecount', callBack)

	function callBack(res) {
		$('#left-approval-chart-approval').html('共' + res.result.total + '个');
		$('#left-approval-chart-em').html(res.result.examinedNum + '个');
		$('#left-approval-chart-al').html(res.result.toExamineNum + '个');
	}
	Ajax('/gov/index/statistics', callOverBack)

	function callOverBack(res) {
		$('#left-approval-chart-site').html('共' + res.result.projectNum + '个');
	}
}
//动火审批表格
function loadApprovalTable(approvalParam) {
	if (approvalParam) {
		type = approvalParam.type;
		projectName = approvalParam.projectName;
		operateReason = approvalParam.operateReason;
		operateLocale = approvalParam.operateLocale;

	} else {
		type = '';
		projectName = '';
		operateReason = '';
		operateLocale = '';
	}
	layui.use('table', function() {
		var table = layui.table;
		//第一个实例
		table.render({
			title: '',
			text: {
				none: '暂无数据'
			},
			elem: '#mid-approval-table',
			skin: 'nob',
			url: ajaxPrefix() + '/gov/fireapply/examine/list',
			headers: {
				SessionId: localStorage.getItem('sessionId')
			},
			where: {
				pageSize: 7,
				type: type,
				projectName: projectName,
				operateReason: operateReason,
				operateLocale: operateLocale
			},
			parseData: function(res) { //res 即为原始返回的数据
				return {
					"code": res.status == 200 ? 0 : 1, //解析接口状态
					"msg": res.message, //解析提示文本
					"count": res.result.total, //解析数据长度
					"data": res.result.data //解析数据列表
				};
			},
			request: {
				pageName: 'pageNum' //页码的参数名称，默认：page
					,
				limitName: 'pageSize' //每页数据量的参数名，默认：limit
			},
			page: {
				limit: 7,
			} //开启分页
			,
			cols: [
				[ //表头
					{
						field: 'status',
						title: '审批状态',
						align: 'center',
						templet: function(d) {
							switch (d.status) {
								case '未通过':
									return `<div><div class="table-tool">
                                    <img src="../static/img/images/icon50.png">${d.status}</div>
                                  </div>`
									break;
								case '审批中':
									return `<div><div class="table-tool">
                                    <img src="../static/img/images/icon48.png">${d.status}</div>
                                  </div>`
									break;
								case '已通过':
									return `<div><div class="table-tool">
                                    <img src="../static/img/images/icon24.png">${d.status}</div>
                                  </div>`
									break;
							}
						},
					}, {
						field: 'contractCompany',
						title: '施工单位',
						align: 'center'
					}, {
						field: 'projectName',
						title: '工地名称',
						align: 'center'
					}, {
						field: 'operateReason',
						title: '动火原因',
						align: 'center'
					}, {
						field: 'fireLocale',
						title: '动火部位',
						align: 'center'
					}, {
						field: 'startTime',
						title: '动火开始时间',
						templet: function(d) {
							return d.startTime == undefined ? '暂无' : d.startTime
						},
						align: 'center'
					}, {
						field: 'endTime',
						title: '动火结束时间',
						templet: function(d) {
							return d.endTime == undefined ? '暂无' : d.endTime
						},
						align: 'center',
					}, {
						field: 'applyUser',
						title: '申请人',
						align: 'center'
					}, {
						title: '操作',
						align: 'center',
						width: 80,
						templet: function(d) {
							return `<div><div class="table-tool">
                                    <div onclick='showDetailsFireApproval(${d.applyId})'><img src="../static/img/images/icon33.png">详情</div>
                                  </div></div>`
						},
					},
				]
			]
		});
	});
}
//多波段火情预警批表格
function loadMultibandfireTable(approvalParam) {
	if (approvalParam) {
		type = approvalParam.type;
		projectName = approvalParam.projectName;
		operateReason = approvalParam.operateReason;
		operateLocale = approvalParam.operateLocale;

	} else {
		type = '';
		projectName = '';
		operateReason = '';
		operateLocale = '';
	}
	layui.use('table', function() {
		var table = layui.table;
		//第一个实例
		table.render({
			title: '',
			text: {
				none: '暂无数据'
			},
			elem: '#mid-multibandfire-table',
			skin: 'nob',
			url: ajaxPrefix() + '/rest/v1/gov/multibandfire/list',
			headers: {
				SessionId: localStorage.getItem('sessionId')
			},
			// ?
			// pageNum = 1 & pageSize = 9 & eventType = & deviceStatus = & nameOrEuid = & startTime = &
			// endTime =
			where: {
				pageSize: 7,
				eventType: type,
				deviceStatus: projectName,
				nameOrEuid: operateReason,
				startTime: operateLocale,
				endTime: operateLocale,
			},
			parseData: function(res) { //res 即为原始返回的数据
				return {
					"code": res.status == 200 ? 0 : 1, //解析接口状态
					"msg": res.message, //解析提示文本
					"count": res.result.total, //解析数据长度
					"data": res.result.data //解析数据列表
				};
			},
			request: {
				pageName: 'pageNum' //页码的参数名称，默认：page
					,
				limitName: 'pageSize' //每页数据量的参数名，默认：limit
			},
			page: {
				limit: 7,
			} //开启分页
			,
			cols: [
				[ //表头
					{
						field: 'status',
						title: '安装地址',
						align: 'center',
						templet: function(d) {
							switch (d.status) {
								case '未通过':
									return `<div><div class="table-tool">
                                    <img src="../static/img/images/icon50.png">${d.status}</div>
                                  </div>`
									break;
								case '审批中':
									return `<div><div class="table-tool">
                                    <img src="../static/img/images/icon48.png">${d.status}</div>
                                  </div>`
									break;
								case '已通过':
									return `<div><div class="table-tool">
                                    <img src="../static/img/images/icon24.png">${d.status}</div>
                                  </div>`
									break;
							}
						},
					}, {
						field: 'contractCompany',
						title: '设备编号',
						align: 'center'
					}, {
						field: 'projectName',
						title: '监控状态',
						align: 'center'
					}, {
						field: 'operateReason',
						title: '上报时间',
						align: 'center'
					}, {
						field: 'fireLocale',
						title: '所属组织',
						align: 'center'
					}, {
						title: '操作',
						align: 'center',
						width: 80,
						templet: function(d) {
							return `<div><div class="table-tool">
                                    <div onclick='showDetailsFireApproval(${d.applyId})'><img src="../static/img/images/icon33.png">详情</div>
                                  </div></div>`
						},
					},
				]
			]
		});
	});
}
/*火眼监测柱形图*/
function fireeyeHistogram() {


	Ajax('/gov/multibandfire/countstatusbyday', overCallback)

	function overCallback(res) {
		let data = res.result
		let timeData = []
		let normalData = []
		let warnData = []
		$.each(data, function(index, el) {
			timeData.push(index)
			normalData.push(el.normal)
			warnData.push(el.warn)
		});
		var option = {
			color: ['#00FFE2', '#FF622D'],
			legend: {
				data: ['正常', '告警'],
				textStyle: {
					color: '#fff'
				}
			},
			tooltip: {
				trigger: 'axis'
			},
			grid: {
				top: '15%',
				left: '5%',
				right: '10%',
				bottom: '5%',
				containLabel: true
			},
			xAxis: [{
				type: 'category',
				boundaryGap: true,
				data: timeData,
				axisTick: {
					alignWithLabel: true
				},
				axisTick: {
					alignWithLabel: true
				},
				axisLine: {
					show: true,
					lineStyle: {
						color: '#54A1F1',
						width: 2
					}
				},
				axisLabel: {
					color: 'white',
					fontSize: '10'
				},
				axisTick: {
					show: false
				},
			}],
			yAxis: [{
				type: 'value',
				minInterval: 1,
				axisLine: {
					show: true,
					lineStyle: {
						color: '#54A1F1',
						width: 2
					}
				},
				splitLine: {
					lineStyle: {
						color: '#112B6F'
					}
				},
				axisLabel: {
					color: 'white',
					fontSize: '10'
				},
				axisTick: {
					show: false
				},
			}],
			series: [{
				name: '正常',
				type: 'bar',
				smooth: true,
				/*label: {
				    normal: {
				        show: true,
				        position: 'top'
				    }
				},*/
				data: normalData
			}, {
				name: '告警',
				type: 'bar',
				smooth: true,
				data: warnData
			}, ]
		};
		var myChart = echarts.init(document.getElementById('left-fireeye-bottom-chart'));
		myChart.setOption(option);
	}

}


//火眼表格
function loadFireeyeTable(fireeyeParam) {
	if (fireeyeParam) {
		type = fireeyeParam.type;
		projectName = fireeyeParam.projectName;
		name = fireeyeParam.deviceName;
		code = fireeyeParam.code;

	} else {
		type = '';
		projectName = '';
		name = '';
		code = '';
	}
	layui.use('table', function() {
		var table = layui.table;
		//第一个实例
		table.render({
			title: '',
			text: {
				none: '暂无数据'
			},
			elem: '#mid-fireeye-list',
			skin: 'nob',
			headers: {
				SessionId: localStorage.getItem('sessionId')
			},
			// url: ajaxPrefix() + '/gov/fireeye/list',
			url: ajaxPrefix() + '/gov/multibandfire/list',
			where: {
				pageSize: 6,
				eventType: type,
				projectName: projectName,
				name: name,
				code: code,

			},
			parseData: function(res) { //res 即为原始返回的数据
				return {
					"code": res.status == 200 ? 0 : 1, //解析接口状态
					"msg": res.message, //解析提示文本
					"count": res.result.total, //解析数据长度
					"data": res.result.data //解析数据列表
				};
			},
			request: {
				pageName: 'pageNum' //页码的参数名称，默认：page
					,
				limitName: 'pageSize' //每页数据量的参数名，默认：limit
			},
			page: {
				limit: 6,
			} //开启分页
			,
			cols: [
				[ //表头
					{
						field: 'address',
						title: '地址',
						align: 'center',
					}, {
						field: 'projectName',
						title: '工地名称',
						align: 'center'
					}, {
						field: 'deviceName',
						title: '设备名称',
						align: 'center'
					}, {
						field: 'deviceCode',
						title: '设备编码',
						align: 'center'
					}, {
						field: 'eventTypeDesc',
						title: '监测状态',
						// templet: function(d) {
						// 	switch (d.eventType) {
						// 		case '正常':
						// 			return `<div><div class="table-tool">
						//                               <img src="../static/img/images/icon26.png">正常</div>
						//                             </div>`;
						// 			break;
						// 		case '烟雾告警':
						// 			return `<div><div class="table-tool">
						//                               <img src="../static/img/images/icon46.png">烟雾告警</div>
						//                             </div>`;
						// 			break;
						// 		case '火警':
						// 			return `<div><div class="table-tool">
						//                               <img src="../static/img/images/icon57.png">火警</div>
						//                             </div>`;
						// 			break;
						// 	}
						// },
						align: 'center'
					}, {
						field: 'contractCompany',
						title: '施工单位',
						align: 'center',
					}, {
						field: 'fireLocale',
						title: '动火点',
						align: 'center',
					}, {
						field: 'chargePerson',
						title: '负责人',
						align: 'center',
					}, {
						field: 'chargeNumber',
						title: '负责人电话',
						align: 'center',
					}, {
						field: 'time',
						title: '上报时间',
						templet: function(d) {
							return d.time == undefined ? '暂无' : d.time
						},
						align: 'center'
					}, {
						title: '操作',
						align: 'center',
						width: 80,
						templet: function(d) {
							let detail = JSON.stringify(d)
							return `<div><div class="table-tool">
                                    <div onclick='showDetailsmultibandfire(` + detail + `)'><img src="../static/img/images/icon33.png">详情</div>
                                  </div></div>`
						},
					},
				]
			]
		});
	});
}
/*多频谱详情*/
showDetailsmultibandfire = (result) => {
	$('.details-fireeye-body>ul').html('');
	var data = result
	let str = '';
	// $('.maintt-item').eq(1).attr("data-deviceId",data.deviceId)

	str = ` <li class="details-fireeye-body-item">
	                <div>地址：</div>
	                <span>${data.address?data.address:''}</span>
	        </li>
			<li class="details-fireeye-body-item">
			        <div>工地名称：</div>
			        <span>${data.projectName?data.projectName:''}</span>
			</li>
			<li class="details-fireeye-body-item">
	                <div>设备名称：</div>
	                <span>${data.deviceName?data.deviceName:''}</span>
	        </li>
			<li class="details-fireeye-body-item">
			        <div>设备编码：</div>
			        <span>${data.deviceCode?data.deviceCode:''}</span>
			</li>
			<li class="details-fireeye-body-item">
			        <div>监控状态：</div>
			        <span>${data.eventTypeDesc?data.eventTypeDesc:''}</span>
			</li>
			<li class="details-fireeye-body-item">
			        <div>施工单位：</div>
			        <span>${data.contractCompany?data.contractCompany:''}</span>
			</li>
			<li class="details-fireeye-body-item">
			        <div>动火点：</div>
			        <span>${data.fireLocale?data.fireLocale:''}</span>
			</li>
			<li class="details-fireeye-body-item">
			        <div>负责人：</div>
			        <span>${data.chargePerson?data.chargePerson:''}</span>
			</li>
			<li class="details-fireeye-body-item">
			        <div>负责人电话：</div>
			        <span>${data.chargeNumber?data.chargeNumber:''}</span>
			</li>
			<li class="details-fireeye-body-item">
			        <div>频率：</div>
			        <span>${data.fre?data.fre:''}</span>
			</li>
			<li class="details-fireeye-body-item">
			        <div>信号强度：</div>
			        <span>${data.signal?data.signal:''}</span>
			</li>
	        <li class="details-fireeye-body-item">
	                <div>上报时间：</div>
	                <span>${checkNullOrEmpty(data.time)}</span>
	        </li>
	        <li class="details-fireeye-body-item">
	                <div>图片：</div>
	                <img onclick="scalePic('','`+data.filePath+`')" src="/images/${data.filePath}">
	        </li>
	
	`
	$('.details-fireeye-body>ul').html(str);

	$('.details-fireeye').show();
}
//火眼历史表格
function loadFireeyeTable_history(deviceId) {
	layui.use('table', function() {
		var table = layui.table;
		//第一个实例
		table.render({
			title: '',
			text: {
				none: '暂无数据'
			},
			elem: '#multibandfire-table-history',
			skin: 'nob',
			headers: {
				SessionId: localStorage.getItem('sessionId')
			},
			// url: ajaxPrefix() + '/gov/fireeye/list',
			url: ajaxPrefix() + '/project/multibandfire/list/history',
			where: {
				pageSize: 6,
				projectId: currentSiteId,
				eventType: '',
				name: '',
				code: '',
				deviceId: deviceId,
			},
			parseData: function(res) { //res 即为原始返回的数据
				return {
					"code": res.status == 200 ? 0 : 1, //解析接口状态
					"msg": res.message, //解析提示文本
					"count": res.result.total, //解析数据长度
					"data": res.result.data //解析数据列表
				};
			},
			request: {
				pageName: 'pageNum' //页码的参数名称，默认：page
					,
				limitName: 'pageSize' //每页数据量的参数名，默认：limit
			},
			page: {
				limit: 6,
			} //开启分页
			,
			cols: [
				[ //表头
					{
						field: 'address',
						title: '地址',
						align: 'center',
					}, {
						field: 'projectName',
						title: '工地名称',
						align: 'center'
					}, {
						field: 'deviceName',
						title: '设备名称',
						align: 'center'
					}, {
						field: 'deviceCode',
						title: '设备编码',
						align: 'center'
					}, {
						field: 'eventTypeDesc',
						title: '监测状态',
						align: 'center'
					}, {
						field: 'contractCompany',
						title: '施工单位',
						align: 'center',
					}, {
						field: 'fireLocale',
						title: '动火点',
						align: 'center',
					}, {
						field: 'chargePerson',
						title: '负责人',
						align: 'center',
					}, {
						field: 'chargeNumber',
						title: '负责人电话',
						align: 'center',
					}, {
						field: 'time',
						title: '上报时间',
						templet: function(d) {
							return d.time == undefined ? '暂无' : d.time
						},
						align: 'center'
					},
				]
			]
		});
	});
}
/*接入工地—動火統計圖*/
function fireRecordByThirtyDays() {
	$('.left-site-record-top>.main-tit>label').html(currentSiteName + ' 七日动火统计图');
	$('.left-site-record-bottom>.main-tit>label').html(currentSiteName + ' 概览');


	Ajax('/project/fireapply/locale/countsevendays?projectId=' + currentSiteId, overCallback)

	function overCallback(res) {
		let data = res.result;
		let timeData = [];
		let warningStatusData = [];
		let num = 0;
		$.each(data, function(index, el) {
			timeData.push(index);
			warningStatusData.push(el);
			num = num + el;
		});
		$('.left-site-record-top-num>span').html('近7日动火' + num + '次')

		var option = {
			color: '#1bd3f6',
			grid: {
				top: '15%',
				left: '5%',
				right: '10%',
				bottom: '5%',
				containLabel: true
			},
			tooltip: {
				trigger: 'axis'
			},
			xAxis: [{
				type: 'category',
				boundaryGap: false,
				data: timeData,
				axisTick: {
					alignWithLabel: true
				},
				axisTick: {
					alignWithLabel: true
				},
				axisLine: {
					show: true,
					lineStyle: {
						color: '#54A1F1',
						width: 2
					}
				},
				axisLabel: {
					color: 'white',
					fontSize: '10'
				},
				axisTick: {
					show: false
				},
			}],
			yAxis: [{
				type: 'value',
				minInterval: 1,
				axisLine: {
					show: true,
					lineStyle: {
						color: '#54A1F1',
						width: 2
					}
				},
				splitLine: {
					show: false,
				},
				axisLabel: {
					color: 'white',
					fontSize: '10'
				},
				axisTick: {
					show: false
				},
			}],
			series: [{
				data: warningStatusData,
				type: 'bar',
				label: {
					normal: {
						show: true,
						position: 'top'
					}
				},

			}]
		};
		var myChart = echarts.init(document.getElementById('left-site-record-top-chart'));
		myChart.setOption(option);
	}
	Ajax('/project/fireapply/statistics?projectId=' + currentSiteId, overviewCallback)

	function overviewCallback(res) {
		$('#left-site-record-days').html(res.result.monitorDays + '天');
		$('#left-site-record-count').html(res.result.operateNum + '次');
	}

}
//动火记录表格
function loadFireRecordTable(type, params) {
	if (type == 1) {
		$('.mid-site-record>.main-tit>label').html(currentSiteName + ' —— 动火记录');
		var url = ajaxPrefix() + '/project/fireapply/list';
		var col = [
			[ //表头
				{
					field: 'status',
					title: '审批状态',
					align: 'center',
					templet: function(d) {
						switch (d.status) {
							case '未通过':
								return `<div><div class="table-tool">
                                    <img src="../static/img/images/icon50.png">${d.status}</div>
                                  </div>`
								break;
							case '审批中':
								return `<div><div class="table-tool">
                                    <img src="../static/img/images/icon48.png">${d.status}</div>
                                  </div>`
								break;
							case '已通过':
								return `<div><div class="table-tool">
                                    <img src="../static/img/images/icon24.png">${d.status}</div>
                                  </div>`
								break;
						}
					},
				}, {
					field: 'contractCompany',
					title: '施工单位',
					align: 'center'
				}, {
					field: 'fireLocale',
					title: '动火部位',
					align: 'center',
				}, {
					field: 'operateReason',
					title: '动火原因',
					align: 'center'
				}, {
					field: 'startTime',
					title: '开始时间',
					templet: function(d) {
						return d.startTime == undefined ? '暂无' : d.startTime
					},
					align: 'center'
				}, {
					title: '操作',
					align: 'center',
					width: 80,
					templet: function(d) {
						return `<div><div class="table-tool">
                                    <div onclick='showDetailsFireRecord(${d.applyId})'><img src="../static/img/images/icon33.png">详情</div>
                                  </div></div>`
					},
				},
			]
		]
	} else {
		$('.mid-site-record>.main-tit>label').html(currentSiteName + ' —— 动火巡检');
		var url = ajaxPrefix() + '/project/fireapply/inspect/listlast';
		var col = [
			[ //表头
				{
					field: 'fireLocale',
					title: '动火点',
					align: 'center'
				}, {
					field: 'operateReason',
					title: '动火原因',
					align: 'center',
				}, {
					field: 'inspectTime',
					title: '巡查时间',
					width: 140,
					align: 'center',
					templet: function(d) {
						return d.inspectTime == undefined ? '暂无' : d.inspectTime
					},
				}, {
					field: 'illegalOperation',
					title: '是否违规',
					width: 120,
					align: 'center'
				}, {
					title: '操作',
					align: 'center',
					width: 160,
					templet: function(d) {
						return `<div>
                            <div class="table-tool">
                                    <div onclick='showDetailsFireApproval(${d.applyId})'><img src="../static/img/images/icon33.png">详情</div>
                                    <img src="../static/img/images/icon45.png">&nbsp;
                                    <div onclick='initDetailsInspectionRecordPage("",${d.applyId})'>巡检记录</div>
                                  </div>
                                  </div>`
					},
				},
			]
		]
	}

	if (params) {
		var operateReason = params.operateReason;
	} else {
		var operateReason = '';
	}
	layui.use('table', function() {
		var table = layui.table;
		//第一个实例
		table.render({
			title: '',
			text: {
				none: '暂无数据'
			},
			elem: '#mid-site-record-list',
			skin: 'nob',
			url: url,
			headers: {
				SessionId: localStorage.getItem('sessionId')
			},
			where: {
				pageSize: 6,
				projectId: currentSiteId,
				operateReason: operateReason,

			},
			parseData: function(res) { //res 即为原始返回的数据
				return {
					"code": res.status == 200 ? 0 : 1, //解析接口状态
					"msg": res.message, //解析提示文本
					"count": res.result.total, //解析数据长度
					"data": res.result.data //解析数据列表
				};
			},
			request: {
				pageName: 'pageNum' //页码的参数名称，默认：page
					,
				limitName: 'pageSize' //每页数据量的参数名，默认：limit
			},
			page: {
				limit: 6,
			} //开启分页
			,
			cols: col
		});
	});
}
/*接入工地—动火巡检表格*/
function fireInspectionByThirtyDays() {
	$('.left-site-inspection-bottom>.main-tit>label').html(currentSiteName + '七日动火巡检');
	$('.left-site-inspection-top>.main-tit>label').html(currentSiteName + '七日动火/巡检次数 ');
	Ajax('/project/fireapply/inspect/countsevendays?projectId=' + currentSiteId, overCallback)

	function overCallback(res) {
		let data = res.result
		let timeData = []
		let warningStatusData = []
		let total = 0;
		$.each(data, function(index, el) {
			total = total + el;
			timeData.push(index)
			warningStatusData.push(el)
		});
		$('.left-site-inspection-bottom-num>span').html('近7日动火巡检' + total + '次')
		var option1 = {
			color: '#fff',
			grid: {
				top: '10%',
				left: '5%',
				right: '5%',
				bottom: '5%',
				containLabel: true
			},
			tooltip: {
				trigger: 'axis'
			},
			xAxis: [{
				type: 'category',
				boundaryGap: false,
				data: timeData,
				axisTick: {
					alignWithLabel: true
				},
				axisTick: {
					alignWithLabel: true
				},
				axisLine: {
					show: true,
					lineStyle: {
						color: '#54A1F1',
						width: 2
					}
				},
				axisLabel: {
					color: 'white',
					fontSize: '10'
				},
				axisTick: {
					show: false
				},
			}],
			yAxis: [{
				type: 'value',
				minInterval: 1,
				axisLine: {
					show: true,
					lineStyle: {
						color: '#54A1F1',
						width: 2
					}
				},
				splitLine: {
					show: false,
				},
				axisLabel: {
					color: 'white',
					fontSize: '10'
				},
				axisTick: {
					show: false
				},
			}],
			series: [{
				data: warningStatusData,
				type: 'line',
				smooth: true,
			}]
		};
		var myChart1 = echarts.init(document.getElementById('left-site-inspection-bottom-chart'));
		myChart1.setOption(option1);
	}
	Ajax('/project/fireapply/inspect/statistics?projectId=' + currentSiteId, overviewCallback)

	function overviewCallback(res) {
		$('#left-site-inspection-top-num-fire').html(res.result.operateNum)
		$('#left-site-inspection-top-num-count').html(res.result.inspectNum)
	}
	Ajax('/project/fireapply/inspect/countbyday?projectId=' + currentSiteId, overChart2Callback)

	function overChart2Callback(res) {
		let data = res.result
		let timeData = []
		let operateNumData = []
		let inspectNumData = []
		$.each(data, function(index, el) {
			timeData.push(index)
			operateNumData.push(el.operateNum)
			inspectNumData.push(el.inspectNum)
		});
		var option2 = {
			color: ['#288d9b', '#3CE6DB'],
			legend: {
				data: ['动火次数', '动火巡检数'],
				bottom: '0%',
				textStyle: {
					color: '#fff'
				}
			},
			tooltip: {
				trigger: 'axis'
			},
			grid: {
				top: '10%',
				left: '0',
				right: '0',
				bottom: '15%',
				containLabel: true
			},
			xAxis: [{
				type: 'category',
				boundaryGap: true,
				data: timeData,
				axisTick: {
					alignWithLabel: true
				},
				axisTick: {
					alignWithLabel: true
				},
				axisLine: {
					show: true,
					lineStyle: {
						color: '#54A1F1',
						width: 2
					}
				},
				axisLabel: {
					color: 'white',
					fontSize: '10'
				},
				axisTick: {
					show: false
				},
			}],
			yAxis: [{
				type: 'value',
				axisLine: {
					show: true,
					lineStyle: {
						color: '#54A1F1',
						width: 2
					}
				},
				splitLine: {
					lineStyle: {
						color: '#112B6F'
					}
				},
				axisLabel: {
					color: 'white',
					fontSize: '10'
				},
				axisTick: {
					show: false
				},
			}],
			series: [{
				name: '动火次数',
				type: 'bar',
				smooth: true,
				/*                    label: {
				                        normal: {
				                            show: true,
				                            position: 'top'
				                        }
				                    },*/
				data: operateNumData
			}, {
				name: '动火巡检数',
				type: 'bar',
				smooth: true,
				data: inspectNumData
			}, ]
		};

		var myChart2 = echarts.init(document.getElementById('left-site-inspection-top-chart'));

		myChart2.setOption(option2);
	}

}


/*detail*/

/*动火申请详情*/
showDetailsFireRecord = (applyId) => {
	$('.details-fire-record-body>ul').html('');
	Ajax('/project/fireapply/info?applyId=' + applyId, callBack)

	function callBack(res) {
		var data = res.result
		let str = '';
		let color
		switch (data.status) {
			case '未通过':
				color = 'red';
				break;
			case '已申请':
				color = '#FFD739';
				break;
			case '审核中':
				color = '#FF622D';
				break;
			case '已审核':
				color = '#3FFF6F';
				break;
		}
		str = `     <li class="details-fire-record-body-item">
                        <div>施工单位：</div>
                        <span>${checkNullOrEmpty(data.contractCompany)}</span>
                    </li>
                    <li class="details-fire-record-body-item">
                        <div>工地名称：</div>
                        <span>${checkNullOrEmpty(data.projectName)}</span>
                    </li>
                    <li class="details-fire-record-body-item">
                        <div>动火原因：</div>
                        <span>${checkNullOrEmpty(data.operateReason)}</span>
                    </li>
                    <li class="details-fire-record-body-item">
                        <div>动火部位：</div>
                        <span>${checkNullOrEmpty(data.fireLocale)}</span>
                    </li>
                    <li class="details-fire-record-body-item">
                        <div>动火开始时间：</div>
                        <span>${checkNullOrEmpty(data.startTime)}</span>
                    </li>
                    <li class="details-fire-record-body-item">
                        <div>动火结束时间：</div>
                        <span>${checkNullOrEmpty(data.endTime)}</span>
                    </li>
                    <li class="details-fire-record-body-item">
                        <div>动火方式：</div>
                        <span>${checkNullOrEmpty(data.operateType)}</span>
                    </li>
                    <li class="details-fire-record-body-item">
                        <div>申请人：</div>
                        <span>${checkNullOrEmpty(data.applyUser)}</span>
                    </li>
                    <li class="details-fire-record-body-item">
                        <div>监护人：</div>
                        <span>${checkNullOrEmpty(data.fireCustodyUser)}</span>
                    </li>
                    <li class="details-fire-record-body-item">
                        <div>施工单位审核人：</div>
                        <span>${checkNullOrEmpty(data.constructCompanyUser)}</span>
                    </li>
                    <li class="details-fire-record-body-item">
                        <div>监理审核人：</div>
                        <span>${checkNullOrEmpty(data.superviseCompanyUser)}</span>
                    </li>
                    <li class="details-fire-record-body-item">
                        <div>审批状态：</div>
                        <span style="color:${color}">${checkNullOrEmpty(data.status)}</span>
                    </li>
                    <li class="details-fire-record-body-item">
                        <div>申请人资格证：</div>
                        <img src="/images/${data.filePath}">
                    </li>`
		$('.details-fire-record-body>ul').html(str);

	}

	$('.details-fire-record').show();
}


/*动火审批详情*/
showDetailsFireApproval = (applyId) => {
	$('.details-fire-approval>ul').html('');
	Ajax('/project/fireapply/info?applyId=' + applyId, callBack)

	function callBack(res) {
		var data = res.result
		let str = '';
		let color
		switch (data.status) {
			case '未通过':
				color = 'red';
				break;
			case '已申请':
				color = '#FFD739';
				break;
			case '审核中':
				color = '#FF622D';
				break;
			case '已审核':
				color = '#3FFF6F';
				break;
		}
		str = `     <li class="details-fire-approval-body-item">
                        <div>施工单位：</div>
                        <span>${checkNullOrEmpty(data.contractCompany)}</span>
                    </li>
                    <li class="details-fire-approval-body-item">
                        <div>工地名称：</div>
                        <span>${checkNullOrEmpty(data.projectName)}</span>
                    </li>
                    <li class="details-fire-approval-body-item">
                        <div>动火原因：</div>
                        <span>${checkNullOrEmpty(data.operateReason)}</span>
                    </li>
                    <li class="details-fire-approval-body-item">
                        <div>动火部位：</div>
                        <span>${checkNullOrEmpty(data.fireLocale)}</span>
                    </li>
                    <li class="details-fire-approval-body-item">
                        <div>动火开始时间：</div>
                        <span>${checkNullOrEmpty(data.startTime)}</span>
                    </li>
                    <li class="details-fire-approval-body-item">
                        <div>动火结束时间：</div>
                        <span>${checkNullOrEmpty(data.endTime)}</span>
                    </li>
                    <li class="details-fire-approval-body-item">
                        <div style="align-self: flex-start;">动火须知：</div>
                        <span>${data.guidance!=null?data.guidance:`
                                <p>1.动火人必须持有特种作业人员操作证、动火证，按操作规程动火。监护人员负责安全。</p></br>
                                <p>2.配有灭火器材，动火前清除5米内易燃易爆物品。</p></br>
                                <p>3.遇有无法清除的易燃物，必须采取防火措施。</p></br>
                                <p>4.结束后必须对现场进行检查，确认无火灾隐患，方可离开。</p></br>
                                <p>5.监护人员在作业前应察看现场，消除隐患；作业中，应跟班看护；作业后，督促做好清理工作。</p>`}</span>
                    </li>
                    <li class="details-fire-approval-body-item">
                        <div>动火方式：</div>
                        <span>${checkNullOrEmpty(data.operateType)}</span>
                    </li>
                    <li class="details-fire-approval-body-item">
                        <div>申请人：</div>
                        <span>${checkNullOrEmpty(data.applyUser)}</span>
                    </li>
                    <li class="details-fire-approval-body-item">
                        <div>监护人：</div>
                        <span>${checkNullOrEmpty(data.fireCustodyUser)}</span>
                    </li>
                    <li class="details-fire-approval-body-item">
                        <div>施工单位审核人：</div>
                        <span>${checkNullOrEmpty(data.constructCompanyUser)}</span>
                    </li>
                    <li class="details-fire-approval-body-item">
                        <div>监理审核人：</div>
                        <span>${checkNullOrEmpty(data.superviseCompanyUser)}</span>
                    </li>
                    <li class="details-fire-approval-body-item">
                        <div>审批状态：</div>
                        <span style="color:${color}">${data.status}</span>
                    </li>
                    <li class="details-fire-approval-body-item">
                        <div>申请人资格证：</div>
                        <img src="/images/${data.filePath}">
                    </li>`
		$('.details-fire-approval-body>ul').html(str);

	}

	$('.details-fire-approval').show();
}


/*动火巡检详情*/
showDetailsInspection = (applyId) => {
	$('.details-inspection-body>ul').html('');
	Ajax('/project/fireapply/info?applyId=' + applyId, callBack)

	function callBack(res) {
		var data = res.result
		let str = '';

		str = `     <li class="details-inspection-body-item">
                        <div>动火点：</div>
                        <span>${data.fireLocale}</span>
                    </li>
                    <li class="details-inspection-body-item">
                        <div>巡查员</div>
                        <span>${data.inspectUser}</span>
                    </li>
                    <li class="details-inspection-body-item">
                        <div>工地名称：</div>
                        <span>${data.projectName}</span>
                    </li>
                    <li class="details-inspection-body-item">
                        <div>动火原因：</div>
                        <span>${data.operateReason}</span>
                    </li>
                    <li class="details-inspection-body-item">
                        <div>动火开始时间：</div>
                        <span>${data.startTime}</span>
                    </li>
                    <li class="details-inspection-body-item">
                        <div>最近巡查时间：</div>
                        <span>${data.lastInspectTime}</span>
                    </li>
                    <li class="details-inspection-body-item">
                        <div>动火结束时间：</div>
                        <span>${data.fireEndTime}</span>
                    </li>
                    <li class="details-inspection-body-item">
                        <div>动火方式：</div>
                        <span>${data.operateType}</span>
                    </li>
                    <li class="details-inspection-body-item">
                        <div>申请人：</div>
                        <span>${data.applyUser}</span>
                    </li>
                    <li class="details-inspection-body-item">
                        <div>监护人：</div>
                        <span>${data.fireCustodyUser}</span>
                    </li>
        `
		$('.details-inspection-body>ul').html(str);

	}

	$('.details-inspection').show();
}

/*动火点巡查记录详情*/
/*分页*/
initDetailsInspectionRecordPage = (pageConf, applyId) => {
	if (pageConf == '') {
		pageConf = {};
		pageConf.pageSize = 3;
		pageConf.currentPage = 1;
	}

	Ajax('/project/fireapply/inspect/list?pageNum=' + pageConf.currentPage + '&pageSize=3&applyId=' + applyId,
		callBack)

	function callBack(res) {

		layui.use('laypage', function() {
			var laypage = layui.laypage;
			laypage.render({
				elem: 'details-inspection-record-page',
				count: res.result.total,
				curr: pageConf.currentPage,
				limit: pageConf.pageSize,
				first: "首页",
				last: "尾页",
				layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'],
				jump: function(obj, first) {
					if (!first) {
						pageConf.currentPage = obj.curr;
						pageConf.pageSize = obj.limit;
						initDetailsInspectionRecordPage(pageConf, applyId);
					}
				}
			});
			showDetailsInspectionRecord(res.result.data); //页面填充
		});
	}

}
showDetailsInspectionRecord = (res) => {
	$('.details-inspection-record-body').html('');

	var data = res;
	let str = '';
	$.each(data, function(index, el) {
		if (el.imageList == null) {
			el.imageList = ['']
		}
		let imgStr = '';
		$.each(el.imageList, function(index, el) {
			imgStr = imgStr + `<div class="swiper-slide">
                <img src="/images/${el}">
            </div>`
		})
		str = str + `
            <div class="details-inspection-record-body-item">
                    <li>
                        <div>巡查时间：</div><span>${el.inspectTime}</span>
                    </li>
                    <li>
                        <div>巡查员：</div><span>${el.inspectUser}</span>
                    </li>
                    <li>
                        <div>是否违规：</div><span>${el.illegalOperation}</span>
                    </li>
                    <li>
                        <div>巡查意见：</div><span>${el.inspectOpinion}</span>
                    </li>
                    <li>
                        <div>图片：</div>
                    </li>
                    <div class="swiper-container swiper1">
						<div class="swiper-wrapper">
						   ${imgStr}
						</div>
						<div class="swiper-pagination"></div>
						<div class="swiper-button-next1 swiper-button-black"></div>
						<div class="swiper-button-prev1 swiper-button-black"></div>
					</div>
            </div>
            `;
	})
	$('.details-inspection-record-body').append(str);
	$('.details-inspection-record').show();
	var swiper = new Swiper('.swiper-container', {
		loop: true, //是否循环，false不循环
		effect: 'cube', //切换效果，不要可删除
		pagination: {
			el: '.swiper-pagination',
			type: 'fraction',
		},
		navigation: {
			nextEl: '.swiper-button-next1',
			prevEl: '.swiper-button-prev1',
		},
	});
}



/*工地页火眼列表*/
/*分页*/
fireeyeCardPageByProject = (pageConf) => {
	if (!pageConf) {
		pageConf = {};
		pageConf.pageSize = 3;
		pageConf.currentPage = 1;
	}

	Ajax('/project/fireeye/list?pageNum=' + pageConf.currentPage + '&pageSize=3&projectId=' + currentSiteId +
		'&deviceName=' + $('.mid-site-fireeye-search-params input').val(), callBack)

	function callBack(res) {

		layui.use('laypage', function() {
			var laypage = layui.laypage;
			laypage.render({
				elem: 'mid-site-fireeye-list-page',
				count: res.result.total,
				curr: pageConf.currentPage,
				limit: pageConf.pageSize,
				first: "首页",
				last: "尾页",
				layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'],
				jump: function(obj, first) {
					if (!first) {
						pageConf.currentPage = obj.curr;
						pageConf.pageSize = obj.limit;
						fireeyeCardPageByProject(pageConf);
					}
				}
			});
			fireeyeCardByProject(res.result.data); //页面填充
		});
	}

}
fireeyeCardByProject = (res) => {
	$('.mid-site-fireeye-list').html('');
	$('.mid-site-fireeye-search>.main-tit>label').html(currentSiteName + ' —— 火眼监测');
	var data = res;
	let str = '';
	$.each(data, function(index, el) {
		let icon;
		switch (el.eventType) {
			case '正常':
				icon = 'icon26';
				break;
			case '烟雾告警':
				icon = 'icon46';
				break;
			case '火警':
				icon = 'icon57';
				break;
		}
		str = str + `
           <div class="mid-site-fireeye-list-item">
                <img src="/images/${el.filePath}">
                <ul>
                    <li>
                        <div>监测状态：</div><span>
                             <img src="../static/img/images/${icon}.png">${el.eventType}
                        </span>
                    </li>
                    <li>
                        <div>设备名称：</div><span>${el.deviceName}</span>
                    </li>
                    <li>
                        <div>最近上报时间：</div><span>${checkNullOrEmpty(el.dataTime)}</span>
                    </li>
                    <li>
                        <div>所属工地：</div><span>${el.projectName}</span>
                    </li>
                    <li>
                        <div>地址：</div><span>${el.address}</span>
                    </li>
                </ul>
                <div>
                    <div onclick="showDetailsFireeye(${el.deviceId},${el.dataId})"><img src="../static/img/images/icon33.png">详情</div>
                    <div onclick="initDetailsFireeyeWarnRecordPage('',${el.deviceId})"><img src="../static/img/images/icon34.png">告警记录</div>
                </div>
            </div>
            `;
	})
	$('.mid-site-fireeye-list').append(str);
}


/*火眼详情*/
showDetailsFireeye = (deviceId, dataId) => {
	$('.details-fireeye-body>ul').html('');
	Ajax('/project/fireeye/device/info?deviceId=' + deviceId + '&dataId=' + dataId, callBack)

	function callBack(res) {
		var data = res.result
		let str = '';

		str = ` <li class="details-fireeye-body-item">
                        <div>设备名称：</div>
                        <span>${data.deviceName}</span>
                </li>
                <li class="details-fireeye-body-item">
                        <div>地址：</div>
                        <span>${data.address}</span>
                </li>
                <li class="details-fireeye-body-item">
                        <div>数据上报时间：</div>
                        <span>${data.dataTime}</span>
                </li>
                <li class="details-fireeye-body-item">
                        <div>当前状态：</div>
                        <span>${data.eventType}</span>
                </li>
                <li class="details-fireeye-body-item">
                        <div>匹配度：</div>
                        <span>${data.matchDegree}</span>
                </li>
                <li class="details-fireeye-body-item">
                        <div>所属工地：</div>
                        <span>${data.projectName}</span>
                </li>
                <li class="details-fireeye-body-item">
                        <div>动火点：</div>
                        <span>${data.fireLocale}</span>
                </li>
                <li class="details-fireeye-body-item">
                        <div>施工单位：</div>
                        <span>${data.contractCompany}</span>
                </li>
                <li class="details-fireeye-body-item">
                        <div>图片：</div>
                        <img src="/images/${data.filePath}">
                </li>

        `
		$('.details-fireeye-body>ul').html(str);

	}

	$('.details-fireeye').show();
}


/*火眼报警列表*/
/*分页*/
initDetailsFireeyeWarnRecordPage = (pageConf, deviceId) => {
	if (pageConf == '') {
		pageConf = {};
		pageConf.pageSize = 3;
		pageConf.currentPage = 1;
	}

	Ajax('/project/fireeye/device/listalert?pageNum=' + pageConf.currentPage + '&pageSize=3&deviceId=' + deviceId,
		callBack)

	function callBack(res) {

		layui.use('laypage', function() {
			var laypage = layui.laypage;
			laypage.render({
				elem: 'details-fireeye-warn-record-page',
				count: res.result.total,
				curr: pageConf.currentPage,
				limit: pageConf.pageSize,
				first: "首页",
				last: "尾页",
				layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'],
				jump: function(obj, first) {
					if (!first) {
						pageConf.currentPage = obj.curr;
						pageConf.pageSize = obj.limit;
						initDetailsFireeyeWarnRecordPage(pageConf, deviceId);
					}
				}
			});
			showDetailsFireeyeWarnRecord(res.result.data); //页面填充
		});
	}

}
showDetailsFireeyeWarnRecord = (res) => {
	$('.details-fireeye-warn-record-body').html('');

	var data = res;
	let str = '';
	$.each(data, function(index, el) {
		str = str + `
            <div class="details-fireeye-warn-record-body-item">
                    <li>
                        <div>上报时间：</div><span>${el.dataTime}</span>
                    </li>
                    <li>
                        <div>当前状态：</div><span>${el.eventType}</span>
                    </li>
                    <li>
                        <span><img src="/images/${el.filePath}"></span>
                    </li>
                </div>
            `;
	})
	$('.details-fireeye-warn-record-body').append(str);
	$('.details-fireeye-warn-record').show();
}

/*查询*/
var searchType;
$('.mid-site-record-tool button').click(function() {
	var params = {};
	if (searchType == 1) {
		params.operateReason = $('.mid-site-record-tool input').val()
		loadFireRecordTable(1, params);
	} else {
		params.operateReason = $('.mid-site-record-tool input').val()
		loadFireRecordTable(2, params);
	}
})



$('.mid-site-fireeye-search-params button').click(function() {
	fireeyeCardPageByProject();
})

var approvalParam = {};
approvalParam.type = "ALL";
$('.mid-approval-search-params button').click(function() {
	approvalParam.projectName = $('.mid-approval-search-params input').eq(0).val();
	approvalParam.operateReason = $('.mid-approval-search-params input').eq(1).val();
	approvalParam.operateLocale = $('.mid-approval-search-params input').eq(2).val();
	loadApprovalTable(approvalParam)
})


var fireeyeParam = {};
fireeyeParam.type = "";
$('.mid-fireeye-table button').click(function() {
	fireeyeParam.projectName = $('.mid-fireeye-table-tool input').eq(0).val();
	fireeyeParam.deviceName = $('.mid-fireeye-table-tool input').eq(1).val();
	fireeyeParam.code = $('.mid-fireeye-table-tool input').eq(2).val();
	loadFireeyeTable(fireeyeParam)
})

var electricalSafetyParam = {};
electricalSafetyParam.type = "";
$('.mid-electricalSafety-table button').click(function() {
    electricalSafetyParam.projectName = $('.mid-electricalSafety-table-tool input').eq(0).val();
    electricalSafetyParam.deviceName = $('.mid-electricalSafety-table-tool input').eq(1).val();
    electricalSafetyParam.code = $('.mid-electricalSafety-table-tool input').eq(2).val();
    loadelectricalSafetyTable(electricalSafetyParam)
})
// 烟感
var yanganParam = {};
yanganParam.type = "";
$('.mid-yangan-table button').click(function() {
    yanganParam.projectName = $('.mid-yangan-table-tool input').eq(0).val();
    yanganParam.deviceName = $('.mid-yangan-table-tool input').eq(1).val();
    yanganParam.code = $('.mid-yangan-table-tool input').eq(2).val();
    loadyanganTable(yanganParam)
})
// 水箱
var shuixiangParam = {};
shuixiangParam.type = "";
$('.mid-shuixiang-table button').click(function() {
    shuixiangParam.projectName = $('.mid-shuixiang-table-tool input').eq(0).val();
    shuixiangParam.deviceName = $('.mid-shuixiang-table-tool input').eq(1).val();
    shuixiangParam.code = $('.mid-shuixiang-table-tool input').eq(2).val();
	console.log(shuixiangParam)
    loadshuixiangTable(shuixiangParam)
})
// 泵水压
var bengshuiyaParam = {};
bengshuiyaParam.type = "";
$('.mid-bengshuiya-table button').click(function() {
    bengshuiyaParam.projectName = $('.mid-bengshuiya-table-tool input').eq(0).val();
    bengshuiyaParam.deviceName = $('.mid-bengshuiya-table-tool input').eq(1).val();
    bengshuiyaParam.code = $('.mid-bengshuiya-table-tool input').eq(2).val();
    loadbengshuiyaTable(bengshuiyaParam)
})



//新添加的功能
var mySwiper = new Swiper('.swiper-container2', {
	slidesPerView: 5,
	slidesPerGroup: 5,
	rewind:true,
	loop:true,
	// spaceBetween : 20,
	// loop: true, // 循环模式选项
	// width: 40, 
	// 如果需要前进后退按钮
	navigation: {
		nextEl: '.swiper-button-next',
		prevEl: '.swiper-button-prev',
	}
})


// 电器火灾
//电气安全表格
function loadelectricalSafetyTable(electricalSafetyParam) {

    if (electricalSafetyParam) {
    	type = electricalSafetyParam.type;
    	projectName = electricalSafetyParam.projectName;
    	name = electricalSafetyParam.deviceName;
    	code = electricalSafetyParam.code;
    
    } else {
    	type = '';
    	projectName = '';
    	name = '';
    	code = '';
    }
    layui.use('table', function() {
        var table = layui.table;
        //第一个实例
        table.render({
            title: '',
            text: {
                none: '暂无数据'
            },
            elem: '#mid-electricalSafety-list',
            skin: 'nob',
            headers: { SessionId: localStorage.getItem('sessionId') },
            url: ajaxPrefix() + '/gov/electric/list',
            where: {
                pageSize: 6,
				projectId:currentSiteId,
                eventType: type,
                projectName: projectName,
                name: name,
                code: code
            },
            parseData: function(res) { //res 即为原始返回的数据
                return {
                    "code": res.status == 200 ? 0 : 1, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.result.total, //解析数据长度
                    "data": res.result.data //解析数据列表
                };
            },
            request: {
                pageName: 'pageNum' //页码的参数名称，默认：page
                    ,
                limitName: 'pageSize' //每页数据量的参数名，默认：limit
            },
            page: {
                limit: 6,
            } //开启分页
            ,
            cols: [
                [ //表头
                    {
                    	field: 'address',
                    	title: '地址',
                    	align: 'center',
                    }, {
                    	field: 'projectName',
                    	title: '工地名称',
                    	align: 'center'
                    }, {
                    	field: 'deviceName',
                    	title: '设备名称',
                    	align: 'center'
                    }, {
                    	field: 'deviceCode',
                    	title: '设备编码',
                    	align: 'center'
                    }, {
                    	field: 'eventTypeDesc',
                    	title: '监测状态',
                    	align: 'center'
                    }, {
                    	field: 'chargePerson',
                    	title: '负责人',
                    	align: 'center',
                    }, {
                    	field: 'chargeNumber',
                    	title: '负责人电话',
                    	align: 'center',
                    }, {
                    	field: 'time',
                    	title: '上报时间',
                    	templet: function(d) {
                    		return d.time == undefined ? '暂无' : d.time
                    	},
                    	align: 'center'
                    }, {
                    	title: '操作',
                    	align: 'center',
                    	width: 80,
                    	templet: function(d) {
                    		let detail = JSON.stringify(d)
                    		return `<div><div class="table-tool">
                                    <div onclick='showDetailelectricalSafety(${detail})'><img src="../static/img/images/icon33.png">详情</div>
                                  </div></div>`
                    	},
                    },
                ]
            ]
        });
    });
}
/*电气安全详情*/
showDetailelectricalSafety = (result) => {
	// $('.details-electricalSafety-body>ul').html('');
	var data = result
	let str = '';
	$('.maintt-item').eq(1).attr("data-deviceId",data.deviceId)
	str = `<li class="detail-basic">
				<div class="detail_title">基本详情</div>
				<div class="detail_content">
					<div class="detail_item">
						<span class="detail_item_name">地址：</span>
						<span class="detail_item_value">${data.address?data.address:''}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">工地名称：</span>
						<span class="detail_item_value">${data.projectName?data.projectName:''}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">设备名称：</span>
						<span class="detail_item_value">${data.deviceName?data.deviceName:''}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">设备编码：</span>
						<span class="detail_item_value">${data.deviceCode?data.deviceCode:''}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">监控状态：</span>
						<span class="detail_item_value">${data.eventTypeDesc?data.eventTypeDesc:''}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">负责人：</span>
						<span class="detail_item_value">${data.chargePerson?data.chargePerson:''}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">负责人电话：</span>
						<span class="detail_item_value">${data.chargeNumber?data.chargeNumber:''}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">信号强度：</span>
						<span class="detail_item_value">${data.signal?data.signal:''}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">上报时间：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.time)}</span>
					</div>
				</div>
			</li>
			<li class="detail-basic">
				<div class="detail_title">电气火灾参数</div>
				<div class="detail_content">
					<div class="detail_item">
						<span class="detail_item_name">温度1(℃)：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.temperatureA)}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">温度2(℃)：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.temperatureB)}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">温度3(℃)：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.temperatureC)}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">温度4(℃)：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.temperatureD)}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">全波剩余电流(mA)：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.fullWaveResidualCurrent)}</span>
					</div>
				</div>
				<div style="margin-top:0.1rem;" class="detail_title">电表基本参数信息</div>
				<div class="detail_content">
					<div class="detail_item">
						<span class="detail_item_name">A相电压(V)：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.voltageA)}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">B相电压(V)：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.voltageB)}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">C相电压(V)：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.voltageC)}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">A相电流(A)：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.currentA)}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">B相电流(A)：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.currentB)}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">C相电流(A)：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.currentC)}</span>
					</div>
				</div>
			</li>`
	
	$('.details-electricalSafety-body>ul').html(str);

	$('.details-electricalSafety').show();
	console.log(data.deviceId)
	echart_electricalSafety(data.deviceId);
}
//电气安全趋势图
function echart_electricalSafety(deviceId) {
	console.log(deviceId)
	var beginDate = getDaysBefore(30);
	var endDate = getCurrentDateOnly();
	Ajax('/project/electric/list/trend?deviceId=' + deviceId + '&beginDate=' + beginDate + '&endDate=' + endDate,
		callBack)

	function callBack(res) {
		let data = res.result
		let timeData = []
		let currentAData = []
		let currentBData = []
		let currentCData = []
		let voltageAData = []
		let voltageBData = []
		let voltageCData = []
		let temperatureAData = []
		let temperatureBData = []
		let temperatureCData = []
		let temperatureDData = []
		let fullWaveResidualCurrentData = []
		$.each(data, function(index, el) {
			timeData.push(el.time)
			currentAData.push(el.currentA)
			currentBData.push(el.currentB)
			currentCData.push(el.currentC)
			voltageAData.push(el.voltageA)
			voltageBData.push(el.voltageB)
			voltageCData.push(el.voltageC)
			temperatureAData.push(el.temperatureA)
			temperatureBData.push(el.temperatureB)
			temperatureCData.push(el.temperatureC)
			temperatureDData.push(el.temperatureD)
			fullWaveResidualCurrentData.push(el.fullWaveResidualCurrent)
		});
		var option = {
			title: {
				//标题位置
				left: 'center', // left的值为'left', 'center', 'right'
				top: 'top', // top middle bottom
				text: '近30天统计图', // 标题文本
				// 标题文本样式
				textStyle: {
					color: '#54A1F1', // 颜色
					fontStyle: 'normal', // 字体风格,'normal','italic','oblique'
					fontWeight: '700', //字体粗细 'normal','bold','bolder','lighter',数值：100-700
					fontFamily: 'sans-serif', //字体系列
					fontSize: 18 //字体大小
				}
			},
			legend: {
				data: ['A相电流(A)', 'B相电流(A)', 'C相电流(A)', 'A相电压(V)', 'B相电压(V)','C相电压(V)','温度1(℃)','温度2(℃)','温度3(℃)','温度4(℃)','全波剩余电流(mA)'],
				top: 'bottom', // top middle bottom
				textStyle: {
					color: '#FFF', // 颜色
					fontStyle: 'normal', // 字体风格,'normal','italic','oblique'
					fontFamily: 'sans-serif', //字体系列
					fontSize: 12 //字体大小
				}
			},
			// color: ["#54A1F1","#1CC9B5"],
			grid: {
				top: '12%',
				left: '1%',
				right: '1%',
				bottom: '13%',
				containLabel: true
			},
			tooltip: {
				trigger: 'axis'
			},
			xAxis: [{
				type: 'category',
				boundaryGap: true,
				data: timeData,
				axisTick: {
					alignWithLabel: true
				},
				axisTick: {
					alignWithLabel: true
				},
				axisLine: {
					show: true,
					lineStyle: {
						color: '#54A1F1',
						width: 2
					}
				},
				axisLabel: {
					color: 'white',
					fontSize: '10'
				},
				axisTick: {
					show: false
				},
			}],
			yAxis: [{
				type: 'value',
				minInterval: 1,
				axisLine: {
					show: true,
					lineStyle: {
						color: '#54A1F1',
						width: 2
					}
				},
				splitLine: {
					lineStyle: {
						color: '#112B6F'
					}
				},
				axisLabel: {
					color: 'white',
					fontSize: '10'
				},
				axisTick: {
					show: false
				},
			}],
			series: [{
				name: 'A相电流(A)',
				data: currentAData,
				type: 'line',
				symbolSize: 10, //拐点大小
				symbolColor: 'red', //拐点大小
				// lineStyle: {
				// 	color: '#54A1F1'
				// },
				smooth: true,
			}, {
				name: 'B相电流(A)',
				data: currentBData,
				type: 'line',
				symbolSize: 10, //拐点大小
				symbolColor: 'red', //拐点大小
				// lineStyle: {
				// 	color: '#1CC9B5'
				// },
				smooth: true,
			}, {
				name: 'C相电流(A)',
				data: currentCData,
				type: 'line',
				symbolSize: 10, //拐点大小
				symbolColor: 'red', //拐点大小
				// lineStyle: {
				// 	color: '#1CC9B5'
				// },
				smooth: true,
			}, {
				name: 'A相电压(V)',
				data: voltageAData,
				type: 'line',
				symbolSize: 10, //拐点大小
				symbolColor: 'red', //拐点大小
				// lineStyle: {
				// 	color: '#1CC9B5'
				// },
				smooth: true,
			}, {
				name: 'B相电压(V)',
				data: voltageBData,
				type: 'line',
				symbolSize: 10, //拐点大小
				symbolColor: 'red', //拐点大小
				// lineStyle: {
				// 	color: '#1CC9B5'
				// },
				smooth: true,
			}, {
				name: 'C相电压(V)',
				data: voltageCData,
				type: 'line',
				symbolSize: 10, //拐点大小
				symbolColor: 'red', //拐点大小
				// lineStyle: {
				// 	color: '#1CC9B5'
				// },
				smooth: true,
			}, {
				name: '温度1(℃)',
				data: temperatureBData,
				type: 'line',
				symbolSize: 10, //拐点大小
				symbolColor: 'red', //拐点大小
				// lineStyle: {
				// 	color: '#1CC9B5'
				// },
				smooth: true,
			}, {
				name: '温度2(℃)',
				data: temperatureCData,
				type: 'line',
				symbolSize: 10, //拐点大小
				symbolColor: 'red', //拐点大小
				// lineStyle: {
				// 	color: '#1CC9B5'
				// },
				smooth: true,
			}, {
				name: '温度3(℃)',
				data: temperatureAData,
				type: 'line',
				symbolSize: 10, //拐点大小
				symbolColor: 'red', //拐点大小
				// lineStyle: {
				// 	color: '#1CC9B5'
				// },
				smooth: true,
			}, {
				name: '温度4(℃)',
				data: temperatureDData,
				type: 'line',
				symbolSize: 10, //拐点大小
				symbolColor: 'red', //拐点大小
				// lineStyle: {
				// 	color: '#1CC9B5'
				// },
				smooth: true,
			}, {
				name: '全波剩余电流(mA)',
				data: fullWaveResidualCurrentData,
				type: 'line',
				symbolSize: 10, //拐点大小
				symbolColor: 'red', //拐点大小
				// lineStyle: {
				// 	color: '#1CC9B5'
				// },
				smooth: true,
			}]
		};
		var myChart = echarts.init(document.getElementById('echartBox_electricalSafety'));
		//使用制定的配置项和数据显示图表
		myChart.setOption(option);
	}
}
////电气安全历史表格
function loadelectricalSafetyTable_history(deviceId) {
	// if (fireeyeParam) {
	// 	projectId = fireeyeParam.type;
	// 	projectName = fireeyeParam.projectName;
	// 	name = fireeyeParam.deviceName;
	// 	code = fireeyeParam.code;

	// } else {
	// 	projectId = '';
	// 	projectName = '';
	// 	name = '';
	// 	code = '';
	// }
	layui.use('table', function() {
		var table = layui.table;
		//第一个实例
		table.render({
			title: '',
			text: {
				none: '暂无数据'
			},
			elem: '#electricalSafety-table-history',
			skin: 'nob',
			headers: {
				SessionId: localStorage.getItem('sessionId')
			},
			// url: ajaxPrefix() + '/gov/fireeye/list',
			url: ajaxPrefix() + '/project/electric/list/history',
			where: {
				pageSize: 6,
				projectId: currentSiteId,
				eventType: '',
				name: '',
				code: '',
				deviceId: deviceId,
			},
			parseData: function(res) { //res 即为原始返回的数据
				return {
					"code": res.status == 200 ? 0 : 1, //解析接口状态
					"msg": res.message, //解析提示文本
					"count": res.result.total, //解析数据长度
					"data": res.result.data //解析数据列表
				};
			},
			request: {
				pageName: 'pageNum' //页码的参数名称，默认：page
					,
				limitName: 'pageSize' //每页数据量的参数名，默认：limit
			},
			page: {
				limit: 6,
			} //开启分页
			,
			cols: [
				[ //表头
				    {
				    	field: 'address',
				    	title: '地址',
				    	align: 'center',
				    }, {
				    	field: 'projectName',
				    	title: '工地名称',
				    	align: 'center'
				    }, {
				    	field: 'deviceName',
				    	title: '设备名称',
				    	align: 'center'
				    }, {
				    	field: 'deviceCode',
				    	title: '设备编码',
				    	align: 'center'
				    }, {
				    	field: 'eventTypeDesc',
				    	title: '监测状态',
				    	align: 'center'
				    }, {
				    	field: 'chargePerson',
				    	title: '负责人',
				    	align: 'center',
				    }, {
				    	field: 'chargeNumber',
				    	title: '负责人电话',
				    	align: 'center',
				    }, {
				    	field: 'time',
				    	title: '上报时间',
				    	templet: function(d) {
				    		return d.time == undefined ? '暂无' : d.time
				    	},
				    	align: 'center'
				    }, {
                    	title: '操作',
                    	align: 'center',
                    	width: 80,
                    	templet: function(d) {
                    		let detail = JSON.stringify(d)
                    		return `<div><div class="table-tool">
                                    <div onclick='showDetailelectricalSafety_history(${detail})'><img src="../static/img/images/icon33.png">详情</div>
                                  </div></div>`
                    	},
                    }
				]
			]
		});
	});
}
/*电气安全详情*/
showDetailelectricalSafety_history = (result) => {
	// $('.details-electricalSafety-body>ul').html('');
	var data = result
	let str = '';
	$('.maintt-item').eq(1).attr("data-deviceId",data.deviceId)
	str = `<li class="detail-basic">
				<div class="detail_title">基本详情</div>
				<div class="detail_content">
					<div class="detail_item">
						<span class="detail_item_name">地址：</span>
						<span class="detail_item_value">${data.address?data.address:''}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">工地名称：</span>
						<span class="detail_item_value">${data.projectName?data.projectName:''}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">设备名称：</span>
						<span class="detail_item_value">${data.deviceName?data.deviceName:''}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">设备编码：</span>
						<span class="detail_item_value">${data.deviceCode?data.deviceCode:''}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">监控状态：</span>
						<span class="detail_item_value">${data.eventTypeDesc?data.eventTypeDesc:''}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">负责人：</span>
						<span class="detail_item_value">${data.chargePerson?data.chargePerson:''}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">负责人电话：</span>
						<span class="detail_item_value">${data.chargeNumber?data.chargeNumber:''}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">信号强度：</span>
						<span class="detail_item_value">${data.signal?data.signal:''}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">上报时间：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.time)}</span>
					</div>
				</div>
			</li>
			<li class="detail-basic">
				<div class="detail_title">电气火灾参数</div>
				<div class="detail_content">
					<div class="detail_item">
						<span class="detail_item_name">温度1(℃)：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.temperatureA)}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">温度2(℃)：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.temperatureB)}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">温度3(℃)：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.temperatureC)}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">温度4(℃)：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.temperatureD)}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">全波剩余电流(mA)：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.fullWaveResidualCurrent)}</span>
					</div>
				</div>
				<div style="margin-top:0.1rem;" class="detail_title">电表基本参数信息</div>
				<div class="detail_content">
					<div class="detail_item">
						<span class="detail_item_name">A相电压(V)：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.voltageA)}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">B相电压(V)：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.voltageB)}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">C相电压(V)：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.voltageC)}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">A相电流(A)：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.currentA)}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">B相电流(A)：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.currentB)}</span>
					</div>
					<div class="detail_item">
						<span class="detail_item_name">C相电流(A)：</span>
						<span class="detail_item_value">${checkNullOrEmpty(data.currentC)}</span>
					</div>
				</div>
			</li>`
	
	$('.details-electricalSafety_history-body>ul').html(str);

	$('.details-electricalSafety_history').show();

}

//烟感表格
function loadyanganTable(yanganParam) {

    if (yanganParam) {
		type = yanganParam.type;
		projectName = yanganParam.projectName;
		name = yanganParam.deviceName;
		code = yanganParam.code;
    
    } else {
    	type = '';
    	projectName = '';
    	name = '';
    	code = '';
    }
    layui.use('table', function() {
        var table = layui.table;
        //第一个实例
        table.render({
            title: '',
            text: {
                none: '暂无数据'
            },
            elem: '#mid-yangan-list',
            skin: 'nob',
            headers: { SessionId: localStorage.getItem('sessionId') },
            url: ajaxPrefix() + '/gov/smoke/list',
            where: {
                pageSize: 6,
				// projectId: currentSiteId,
				// eventType: type,
				projectName: projectName,
				name: name,
				code: code,
				dataType: type
            },
            parseData: function(res) { //res 即为原始返回的数据
                return {
                    "code": res.status == 200 ? 0 : 1, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.result.total, //解析数据长度
                    "data": res.result.data //解析数据列表
                };
            },
            request: {
                pageName: 'pageNum' //页码的参数名称，默认：page
                    ,
                limitName: 'pageSize' //每页数据量的参数名，默认：limit
            },
            page: {
                limit: 6,
            } //开启分页
            ,
            cols: [
                [ //表头
                    {
                    	field: 'address',
                    	title: '地址',
                    	align: 'center',
                    },
					{
						field: 'projectName',
						title: '工地名称',
						align: 'center',
					},{
                    	field: 'deviceName',
                    	title: '设备名称',
                    	align: 'center'
                    }, {
                    	field: 'deviceCode',
                    	title: '设备编码',
                    	align: 'center'
                    }, {
                    	field: 'eventTypeDesc',
                    	title: '监测状态',
                    	align: 'center'
                    }, {
                    	field: 'chargePerson',
                    	title: '负责人',
                    	align: 'center',
                    }, {
                    	field: 'chargeNumber',
                    	title: '负责人电话',
                    	align: 'center',
                    }, {
                    	field: 'time',
                    	title: '上报时间',
                    	templet: function(d) {
                    		return d.time == undefined ? '暂无' : d.time
                    	},
                    	align: 'center'
                    }, {
                    	title: '操作',
                    	align: 'center',
                    	width: 80,
                    	templet: function(d) {
                    		let detail = JSON.stringify(d)
                    		return `<div><div class="table-tool">
                                    <div onclick='showDetailsYangan(${detail})'><img src="../static/img/images/icon33.png">详情</div>
                                  </div></div>`
                    	},
                    },
                ]
            ]
        });
    });
}
/*烟感详情*/
var yangan_deviceId = '';
showDetailsYangan = (info) => {
    $('.details-shuixiang-body>ul').html('');
	
	var data = info
	let str = '';
	yangan_deviceId = data.deviceId;
	
	str =  `<li class="details-inspection-body-item">
				<div>地址：</div>
				<span>${checkNullOrEmpty(data.address)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>所属工地：</div>
				<span>${checkNullOrEmpty(data.projectName)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>设备名称</div>
				<span>${checkNullOrEmpty(data.deviceName)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>设备编码：</div>
				<span>${checkNullOrEmpty(data.deviceCode)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>监测状态：</div>
				<span>${checkNullOrEmpty(data.eventTypeDesc)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>负责人：</div>
				<span>${checkNullOrEmpty(data.chargePerson)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>负责人电话：</div>
				<span>${checkNullOrEmpty(data.chargeNumber)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>上报时间：</div>
				<span>${checkNullOrEmpty(data.time)}</span>
			</li>`
	$('.details-yangan-body>ul').html(str);

    $('.details-yangan').show();
	loadyanganTable_history(info.deviceId)
}
//烟感设备历史表格
function loadyanganTable_history() {

	// if (yanganParam) {
	// 	type = yanganParam.type;
	// 	// projectName = yanganParam.projectName;
	// 	name = yanganParam.deviceName;
	// 	code = yanganParam.code;

	// } else {
	// 	type = '';
	// 	projectName = '';
	// 	name = '';
	// 	code = '';
	// }
	layui.use('table', function() {
		var table = layui.table;
		//第一个实例
		table.render({
			title: '',
			text: {
				none: '暂无数据'
			},
			elem: '#yangan-table-history',
			skin: 'nob',
			headers: {
				SessionId: localStorage.getItem('sessionId')
			},
			url: ajaxPrefix() + '/project/smoke/list/history',
			where: {
				pageSize: 6,
				projectId: currentSiteId,
				eventType: '',
				// projectName: projectName,
				name: '',
				code: '',
				deviceId: yangan_deviceId
			},
			parseData: function(res) { //res 即为原始返回的数据
				return {
					"code": res.status == 200 ? 0 : 1, //解析接口状态
					"msg": res.message, //解析提示文本
					"count": res.result.total, //解析数据长度
					"data": res.result.data //解析数据列表
				};
			},
			request: {
				pageName: 'pageNum' //页码的参数名称，默认：page
					,
				limitName: 'pageSize' //每页数据量的参数名，默认：limit
			},
			page: {
				limit: 6,
			} //开启分页
			,
			cols: [
				[ //表头
					{
						field: 'address',
						title: '地址',
						align: 'center',
					}, {
						field: 'deviceName',
						title: '设备名称',
						align: 'center'
					}, {
						field: 'deviceCode',
						title: '设备编码',
						align: 'center'
					}, {
						field: 'eventTypeDesc',
						title: '监测状态',
						align: 'center'
					}, {
						field: 'chargePerson',
						title: '负责人',
						align: 'center',
					}, {
						field: 'chargeNumber',
						title: '负责人电话',
						align: 'center',
					}, {
						field: 'time',
						title: '上报时间',
						templet: function(d) {
							return d.time == undefined ? '暂无' : d.time
						},
						align: 'center'
					}
				]
			]
		});
	});
}
//水箱表格
function loadshuixiangTable(shuixiangParam) {

	if (shuixiangParam) {
		type = shuixiangParam.type;
		projectName = shuixiangParam.projectName;
		name = shuixiangParam.deviceName;
		code = shuixiangParam.code;

	} else {
		type = '';
		projectName = '';
		name = '';
		code = '';
	}
    layui.use('table', function() {
        var table = layui.table;
        //第一个实例
        table.render({
            title: '',
            text: {
                none: '暂无数据'
            },
            elem: '#mid-shuixiang-list',
            skin: 'nob',
            headers: { SessionId: localStorage.getItem('sessionId') },
            url: ajaxPrefix() + '/gov/firebox/list',
            where: {
				pageSize: 6,
				projectId: currentSiteId,
				// eventType: type,
				projectName: projectName,
				name: name,
				code: code,
				dataType: type
            },
            parseData: function(res) { //res 即为原始返回的数据
                return {
                    "code": res.status == 200 ? 0 : 1, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.result.total, //解析数据长度
                    "data": res.result.data //解析数据列表
                };
            },
            request: {
                pageName: 'pageNum' //页码的参数名称，默认：page
                    ,
                limitName: 'pageSize' //每页数据量的参数名，默认：limit
            },
            page: {
                limit: 6,
            } //开启分页
            ,
            cols: [
                [ //表头
                    {
                    	field: 'address',
                    	title: '地址',
                    	align: 'center',
                    }, {
                    	field: 'projectName',
                    	title: '工地名称',
                    	align: 'center',
                    },{
                    	field: 'deviceName',
                    	title: '设备名称',
                    	align: 'center'
                    }, {
                    	field: 'deviceCode',
                    	title: '设备编码',
                    	align: 'center'
                    }, {
                    	field: 'eventTypeDesc',
                    	title: '监测状态',
                    	align: 'center'
                    }, {
                    	field: 'depth',
                    	title: '液位(m)',
                    	align: 'center'
                    }, {
                    	field: 'tonnage',
                    	title: '吨位(t)',
                    	align: 'center'
                    }, {
                    	field: 'chargePerson',
                    	title: '负责人',
                    	align: 'center',
                    }, {
                    	field: 'chargeNumber',
                    	title: '负责人电话',
                    	align: 'center',
                    }, {
                    	field: 'time',
                    	title: '上报时间',
                    	templet: function(d) {
                    		return d.time == undefined ? '暂无' : d.time
                    	},
                    	align: 'center'
                    }, {
                    	title: '操作',
                    	align: 'center',
                    	width: 80,
                    	templet: function(d) {
                    		let detail = JSON.stringify(d)
                    		return `<div><div class="table-tool">
                                    <div onclick='showDetailsShuixiang(${detail})'><img src="../static/img/images/icon33.png">详情</div>
                                  </div></div>`
                    	},
                    },
                ]
            ]
        });
    });
}
var shuixiang_deviceId = ''
showDetailsShuixiang = (info) => {
	$('.details-shuixiang-body>ul').html('');

	var data = info
	let str = '';
	shuixiang_deviceId = data.deviceId;
	str = `<li class="details-inspection-body-item">
				<div>地址：</div>
				<span>${checkNullOrEmpty(data.address)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>所属工地：</div>
				<span>${checkNullOrEmpty(data.projectName)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>设备名称</div>
				<span>${checkNullOrEmpty(data.deviceName)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>设备编码：</div>
				<span>${checkNullOrEmpty(data.deviceCode)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>监测状态：</div>
				<span>${checkNullOrEmpty(data.eventTypeDesc)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>长(m)：</div>
				<span>${checkNullOrEmpty(data.length)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>宽(m)：</div>
				<span>${checkNullOrEmpty(data.width)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>高(m)：</div>
				<span>${checkNullOrEmpty(data.height)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>低位阈值(m)：</div>
				<span>${checkNullOrEmpty(data.lowThreshold)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>高位阈值(m)：</div>
				<span>${checkNullOrEmpty(data.highThreshold)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>负责人：</div>
				<span>${checkNullOrEmpty(data.chargePerson)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>负责人电话：</div>
				<span>${checkNullOrEmpty(data.chargeNumber)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>上报时间：</div>
				<span>${checkNullOrEmpty(data.time)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>simID：</div>
			    <span>${data.simId}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>信号强度：</div>
			    <span>${data.signal}</span>
			</li>`
	$('.details-shuixiang-body>ul').html(str);

	$('.details-shuixiang').show();
	echart_shuixiang(shuixiang_deviceId)
	loadshuixiangTable_history()
}
//水箱趋势图
function echart_shuixiang(deviceId) {
	var beginDate = getDaysBefore(30);
	var endDate = getCurrentDateOnly();
	Ajax('/project/firebox/list/trend?deviceId=' + deviceId + '&beginDate=' + beginDate + '&endDate=' + endDate,
		callBack)

	function callBack(res) {
		let data = res.result
		let timeData = []
		let depthData = []
		let tonnageData = []
		$.each(data, function(index, el) {
			timeData.push(el.time)
			depthData.push(el.depth)
			tonnageData.push(el.tonnage)
		});
		var option = {
			title: {
				//标题位置
				left: 'center', // left的值为'left', 'center', 'right'
				top: 'top', // top middle bottom
				text: '近30天统计图', // 标题文本
				// 标题文本样式
				textStyle: {
					color: '#54A1F1', // 颜色
					fontStyle: 'normal', // 字体风格,'normal','italic','oblique'
					fontWeight: '700', //字体粗细 'normal','bold','bolder','lighter',数值：100-700
					fontFamily: 'sans-serif', //字体系列
					fontSize: 18 //字体大小
				}
			},
			legend: {
				data: ['液位', '吨位'],
				top: 'bottom', // top middle bottom
				textStyle: {
					color: '#FFF', // 颜色
					fontStyle: 'normal', // 字体风格,'normal','italic','oblique'
					fontFamily: 'sans-serif', //字体系列
					fontSize: 12 //字体大小
				}
			},
			color: ["#54A1F1", "#1CC9B5"],
			grid: {
				top: '12%',
				left: '1%',
				right: '1%',
				bottom: '13%',
				containLabel: true
			},
			tooltip: {
				trigger: 'axis',
				formatter: function (params) {
					return params[0].name + '<br />' + params[0].seriesName + ': ' + params[0].value +'m'+'<br />'+ params[1].seriesName + ': ' + params[1].value+'t';
				}
			},
			xAxis: [{
				type: 'category',
				boundaryGap: true,
				data: timeData,
				axisTick: {
					alignWithLabel: true
				},
				axisTick: {
					alignWithLabel: true
				},
				axisLine: {
					show: true,
					lineStyle: {
						color: '#54A1F1',
						width: 2
					}
				},
				axisLabel: {
					color: 'white',
					fontSize: '10'
				},
				axisTick: {
					show: false
				},
			}],
			yAxis: [{
				type: 'value',
				minInterval: 1,
				axisLine: {
					show: true,
					lineStyle: {
						color: '#54A1F1',
						width: 2
					}
				},
				splitLine: {
					lineStyle: {
						color: '#112B6F'
					}
				},
				axisLabel: {
					color: 'white',
					fontSize: '10'
				},
				axisTick: {
					show: false
				},
			}],
			series: [{
				name: '液位',
				data: depthData,
				type: 'line',
				symbolSize: 10, //拐点大小
				symbolColor: 'red', //拐点大小
				lineStyle: {
					color: '#54A1F1'
				},
				smooth: true,
			}, {
				name: '吨位',
				data: tonnageData,
				type: 'line',
				symbolSize: 10, //拐点大小
				symbolColor: 'red', //拐点大小
				lineStyle: {
					color: '#1CC9B5'
				},
				smooth: true,
			}]
		};
		var myChart = echarts.init(document.getElementById('echartBox_shuixiang'));
		//使用制定的配置项和数据显示图表
		myChart.setOption(option);
	}
}
//水箱表格
function loadshuixiangTable_history() {

	// if (shuixiangParam) {
	// 	// type = yanganParam.type;
	// 	// projectName = yanganParam.projectName;
	// 	name = shuixiangParam.deviceName;
	// 	code = shuixiangParam.code;

	// } else {
	// 	type = '';
	// 	projectName = '';
	// 	name = '';
	// 	code = '';
	// }
	layui.use('table', function() {
		var table = layui.table;
		//第一个实例
		table.render({
			title: '',
			text: {
				none: '暂无数据'
			},
			elem: '#shuixiang-table-history',
			skin: 'nob',
			headers: {
				SessionId: localStorage.getItem('sessionId')
			},
			url: ajaxPrefix() + '/project/firebox/list/history',
			where: {
				pageSize: 6,
				// projectId: currentSiteId,
				// eventType: type,
				// projectName: projectName,
				name: '',
				code: '',
				deviceId: shuixiang_deviceId
			},
			parseData: function(res) { //res 即为原始返回的数据
				return {
					"code": res.status == 200 ? 0 : 1, //解析接口状态
					"msg": res.message, //解析提示文本
					"count": res.result.total, //解析数据长度
					"data": res.result.data //解析数据列表
				};
			},
			request: {
				pageName: 'pageNum' //页码的参数名称，默认：page
					,
				limitName: 'pageSize' //每页数据量的参数名，默认：limit
			},
			page: {
				limit: 6,
			} //开启分页
			,
			cols: [
				[ //表头
					{
						field: 'address',
						title: '地址',
						align: 'center',
					}, {
						field: 'deviceName',
						title: '设备名称',
						align: 'center'
					}, {
						field: 'deviceCode',
						title: '设备编码',
						align: 'center'
					}, {
						field: 'eventTypeDesc',
						title: '监测状态',
						align: 'center'
					}, {
						field: 'depth',
						title: '液位(m)',
						align: 'center'
					}, {
						field: 'tonnage',
						title: '吨位(t)',
						align: 'center'
					}, {
						field: 'chargePerson',
						title: '负责人',
						align: 'center',
					}, {
						field: 'chargeNumber',
						title: '负责人电话',
						align: 'center',
					}, {
						field: 'time',
						title: '上报时间',
						templet: function(d) {
							return d.time == undefined ? '暂无' : d.time
						},
						align: 'center'
					}
				]
			]
		});
	});
}
//泵水压表格
function loadbengshuiyaTable(bengshuiyaParam) {

    if (bengshuiyaParam) {
    	type = bengshuiyaParam.type;
    	projectName = bengshuiyaParam.projectName;
    	name = bengshuiyaParam.deviceName;
    	code = bengshuiyaParam.code;
    
    } else {
    	type = '';
    	projectName = '';
    	name = '';
    	code = '';
    }
    layui.use('table', function() {
        var table = layui.table;
        //第一个实例
        table.render({
            title: '',
            text: {
                none: '暂无数据'
            },
            elem: '#mid-bengshuiya-list',
            skin: 'nob',
            headers: { SessionId: localStorage.getItem('sessionId') },
            url: ajaxPrefix() + '/gov/firepump/list',
            where: {
                pageSize: 6,
                // projectId: currentSiteId,
                // eventType: type,
                projectName: projectName,
                name: name,
                code: code,
                dataType: type
            },
            parseData: function(res) { //res 即为原始返回的数据
                return {
                    "code": res.status == 200 ? 0 : 1, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.result.total, //解析数据长度
                    "data": res.result.data //解析数据列表
                };
            },
            request: {
                pageName: 'pageNum' //页码的参数名称，默认：page
                    ,
                limitName: 'pageSize' //每页数据量的参数名，默认：limit
            },
            page: {
                limit: 6,
            } //开启分页
            ,
            cols: [
                [ //表头
                    {
                    	field: 'address',
                    	title: '地址',
                    	align: 'center',
                    },{
                    	field: 'projectName',
                    	title: '工地名称',
                    	align: 'center',
                    }, {
                    	field: 'deviceName',
                    	title: '设备名称',
                    	align: 'center'
                    }, {
                    	field: 'deviceCode',
                    	title: '设备编码',
                    	align: 'center'
                    }, {
                    	field: 'eventTypeDesc',
                    	title: '监测状态',
                    	align: 'center'
                    }, {
                    	field: 'pressure',
                    	title: '水压值(MPa)',
                    	align: 'center'
                    }, {
                    	field: 'chargePerson',
                    	title: '负责人',
                    	align: 'center',
                    }, {
                    	field: 'chargeNumber',
                    	title: '负责人电话',
                    	align: 'center',
                    }, {
                    	field: 'time',
                    	title: '上报时间',
                    	templet: function(d) {
                    		return d.time == undefined ? '暂无' : d.time
                    	},
                    	align: 'center'
                    }, {
                    	title: '操作',
                    	align: 'center',
                    	width: 80,
                    	templet: function(d) {
                    		let detail = JSON.stringify(d)
                    		return `<div><div class="table-tool">
                                    <div onclick='showDetailsbengshuiya(${detail})'><img src="../static/img/images/icon33.png">详情</div>
                                  </div></div>`
                    	},
                    },
                ]
            ]
        });
    });
}
/*泵水压详情*/
var bengshuiya_deviceId = '';
showDetailsbengshuiya = (info) => {
	$('.details-bengshuiya-body>ul').html('');

	var data = info
	let str = '';
	bengshuiya_deviceId = data.deviceId;

	str = `<li class="details-inspection-body-item">
				<div>地址：</div>
				<span>${checkNullOrEmpty(data.address)}</span>
			</li>
			<li class="details-inspection-body-item">
						<div>工地名称：</div>
						<span>${checkNullOrEmpty(data.projectName)}</span>
					</li>
			<li class="details-inspection-body-item">
				<div>设备名称</div>
				<span>${checkNullOrEmpty(data.deviceName)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>设备编码：</div>
				<span>${checkNullOrEmpty(data.deviceCode)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>监测状态：</div>
				<span>${checkNullOrEmpty(data.eventTypeDesc)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>水压值(MPa)：</div>
				<span>${checkNullOrEmpty(data.pressure)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>负责人：</div>
				<span>${checkNullOrEmpty(data.chargePerson)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>负责人电话：</div>
				<span>${checkNullOrEmpty(data.chargeNumber)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>上报时间：</div>
				<span>${checkNullOrEmpty(data.time)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>simID：</div>
				<span>${checkNullOrEmpty(data.simId)}</span>
			</li>
			<li class="details-inspection-body-item">
				<div>信号强度：</div>
				<span>${checkNullOrEmpty(data.signal)}</span>
			</li>`
	$('.details-bengshuiya-body>ul').html(str);

	$('.details-bengshuiya').show();
	echart_bengshuiya(bengshuiya_deviceId)
	loadbengshuiyaTable_history();
}
//消防泵趋势图
function echart_bengshuiya(deviceId) {
	var beginDate = getDaysBefore(30);
	var endDate = getCurrentDateOnly();
	Ajax('/project/firepump/list/trend?deviceId=' + deviceId + '&beginDate=' + beginDate + '&endDate=' + endDate,
		callBack)

	function callBack(res) {
		let data = res.result
		let timeData = []
		let pressureData = []
		$.each(data, function(index, el) {
			timeData.push(el.time)
			pressureData.push(el.pressure)
		});
		var option = {
			title: {
				//标题位置
				left: 'center', // left的值为'left', 'center', 'right'
				top: 'top', // top middle bottom
				text: '近30天统计图', // 标题文本
				// 标题文本样式
				textStyle: {
					color: '#54A1F1', // 颜色
					fontStyle: 'normal', // 字体风格,'normal','italic','oblique'
					fontWeight: '700', //字体粗细 'normal','bold','bolder','lighter',数值：100-700
					fontFamily: 'sans-serif', //字体系列
					fontSize: 18 //字体大小
				}
			},
			legend: {
				data: ['水压'],
				top: 'bottom', // top middle bottom
				textStyle: {
					color: '#FFF', // 颜色
					fontStyle: 'normal', // 字体风格,'normal','italic','oblique'
					fontFamily: 'sans-serif', //字体系列
					fontSize: "14" //字体大小
				}
			},
			color: '#fff',
			grid: {
				top: '12%',
				left: '1%',
				right: '1%',
				bottom: '13%',
				containLabel: true
			},
			tooltip: {
				trigger: 'axis',
				formatter: function (params) {
					return params[0].name + '<br />' + params[0].seriesName + ': ' + params[0].value +'MPa';
				}
			},
			xAxis: [{
				type: 'category',
				boundaryGap: true,
				data: timeData,
				axisTick: {
					alignWithLabel: true
				},
				axisTick: {
					alignWithLabel: true
				},
				axisLine: {
					show: true,
					lineStyle: {
						color: '#54A1F1',
						width: 2
					}
				},
				axisLabel: {
					color: 'white',
					fontSize: '14'
				},
				axisTick: {
					show: false
				},
			}],
			yAxis: [{
				type: 'value',
				minInterval: 1,
				axisLine: {
					show: true,
					lineStyle: {
						color: '#54A1F1',
						width: 2
					}
				},
				splitLine: {
					lineStyle: {
						color: '#112B6F'
					}
				},
				axisLabel: {
					color: 'white',
					fontSize: '14'
				},
				axisTick: {
					show: false
				},
			}],
			series: [{
				name: "水压",
				data: pressureData,
				type: 'line',
				symbolSize: 10, //拐点大小
				symbolColor: 'red', //拐点大小
				lineStyle: {
					color: '#54A1F1'
				},
				smooth: true,
			}]
		};
		var myChart = echarts.init(document.getElementById('echartBox_bengshuiya'));
		//使用制定的配置项和数据显示图表
		myChart.setOption(option);
	}
}
//泵水压历史表格
function loadbengshuiyaTable_history() {

	// if (bengshuiyaParam) {
	// 	// type = yanganParam.type;
	// 	// projectName = yanganParam.projectName;
	// 	name = bengshuiyaParam.deviceName;
	// 	code = bengshuiyaParam.code;

	// } else {
	// 	type = '';
	// 	projectName = '';
	// 	name = '';
	// 	code = '';
	// }
	layui.use('table', function() {
		var table = layui.table;
		//第一个实例
		table.render({
			title: '',
			text: {
				none: '暂无数据'
			},
			elem: '#bengshuiya-table-history',
			skin: 'nob',
			headers: {
				SessionId: localStorage.getItem('sessionId')
			},
			url: ajaxPrefix() + '/project/firepump/list/history',
			where: {
				pageSize: 6,
				projectId: currentSiteId,
				// eventType: type,
				// projectName: projectName,
				name: "",
				code: "",
				deviceId: bengshuiya_deviceId
			},
			parseData: function(res) { //res 即为原始返回的数据
				return {
					"code": res.status == 200 ? 0 : 1, //解析接口状态
					"msg": res.message, //解析提示文本
					"count": res.result.total, //解析数据长度
					"data": res.result.data //解析数据列表
				};
			},
			request: {
				pageName: 'pageNum' //页码的参数名称，默认：page
					,
				limitName: 'pageSize' //每页数据量的参数名，默认：limit
			},
			page: {
				limit: 6,
			} //开启分页
			,
			cols: [
				[ //表头
					{
						field: 'address',
						title: '地址',
						align: 'center',
					},{
						field: 'projectName',
						title: '工地名称',
						align: 'center',
					}, {
						field: 'deviceName',
						title: '设备名称',
						align: 'center'
					}, {
						field: 'deviceCode',
						title: '设备编码',
						align: 'center'
					}, {
						field: 'eventTypeDesc',
						title: '监测状态',
						align: 'center'
					}, {
						field: 'pressure',
						title: '水压值(MPa)',
						align: 'center'
					}, {
						field: 'chargePerson',
						title: '负责人',
						align: 'center',
					}, {
						field: 'chargeNumber',
						title: '负责人电话',
						align: 'center',
					}, {
						field: 'time',
						title: '上报时间',
						templet: function(d) {
							return d.time == undefined ? '暂无' : d.time
						},
						align: 'center'
					}
				]
			]
		});
	});
}